[email protected] Posted April 15, 2016 Share Posted April 15, 2016 (edited) Hello to all.BEFOREi made module, showing at hook displayProductListReviews (i.e. in the product list in each product) the quantity in cart, with buttons + - on js. Developed, of course with cache disabled, it works, on all pages where there is a hook, lightly tested, everything is OK. But as soon as turned on the cache, then immediately went bugs on the main page in the modules "new", "featured", and "pricedrops".WHAT I FIND1) on main page there are not output variables to javascript, unlike the other pages, while the store itself does not suffer, but the module has nothing.2) when the cache is ON in the modules"new", "featured", and "pricedrops" through the hook displayProductListReviews in the template product-lis.in tpl the variable $product for each product comes one same product data (first in DB response), i.e. the same ID, etc. How can it be I'll never know, because the products themselves are different, and after the hook comes out the same for everyone. If you disable the cache - all OK, each product come as expected their data.Can't understand this is a Presta bug? or I didn't consider how hooks working with cache?If I didn't check the cache, then how to do it? The issue is on default version the Presta (others as well), so all module files have a default code.Help, please. public function hookDisplayProductListReviews($params) { $cart = $this->context->cart; $in_cart_count_total = Cart::getNbProducts((int)$this->context->cart->id); $id_product = (int)$params['product']['id_product']; $product_in_cart_count = $this->productInCartCount($id_product); $send_arr = array( 'product_2' => $params['product'], 'product_in_cart' => $this->getProductFromCart($id_product), 'in_cart_count' => $product_in_cart_count, 'id_customization' => (int)Tools::getValue('id_customization'), 'priceDisplay' => 1, 'currency' => $this->context->currency ); } $this->smarty->assign($send_arr); return $this->display(__FILE__, 'incartquantity.tpl', null, null); } incartquantity.tpl code: <!-- InCartQuantity module --> <div class="in_cart_qty"> <div class="in_cart_qty_label{if $in_cart_count > 0} marked{/if}"> {l s='in cart' mod='incartquantity'}<span class="remove"{if $in_cart_count < 1} style="display:none;"{/if}><i class="icon-times-circle"></i></span> </div> <div class="cart_quantity_button clearfix"> <a id="cart_quantity_down_{$product_2.id_product}_{$product_2.id_product_attribute}_{$id_customization}_{$product_2.id_address_delivery|intval}" class="cart_quantity_down btn btn-default button-minus" rel="nofollow" title="{l s='Subtract'}"> <span><i class="icon-minus"></i></span> </a> <input type="hidden" value="{$in_cart_count}" name="quantity_{$product_2.id_product}_{$product_2.id_product_attribute}_{$id_customization}_{$product_2.id_address_delivery|intval}_hidden"/> <input type="text" value="{$in_cart_count}" class="cart_quantity_input form-control grey" name="quantity_{$product_2.id_product}_{$product_2.id_product_attribute}_{$id_customization}_{$product_2.id_address_delivery|intval}"/> <a id="cart_quantity_up_{$product_2.id_product}_{$product_2.id_product_attribute}_{$id_customization}_{$product_2.id_address_delivery|intval}" class="cart_quantity_up btn btn-default button-plus" rel="nofollow" title="{l s='Add'}"> <span><i class="icon-plus"></i></span> </a> </div> <div> {if (!$PS_CATALOG_MODE AND ((isset($product_2.show_price) && $product_2.show_price) || (isset($product_2.available_for_order) && $product_2.available_for_order)))} {if isset($product_in_cart) && isset($product_in_cart.price) && $product_in_cart} <span class="price">{l s='=' mod='incartquantity'}{convertPrice price=$product_in_cart.price|floatval*$product_in_cart.cart_quantity}</span> {else} <span class="price" style="display:none;">{l s='=' mod='incartquantity'}</span> {/if} {/if} </div> </div> <!-- /InCartQuantity module --> {strip} {addJsDef currencySign=$currencySign|html_entity_decode:2:"UTF-8"} {addJsDef currencyRate=$currencyRate|floatval} {addJsDef currencyFormat=$currencyFormat} {addJsDef currencyBlank=$currencyBlank|intval} {addJsDef deliveryAddress=$cart->id_address_delivery|intval} {addJsDefL name=txtProduct}{l s='product' js=1}{/addJsDefL} {addJsDefL name=txtProducts}{l s='products' js=1}{/addJsDefL} {addJsDefL name=txtEquals}{l s='=' js=1}{/addJsDefL} {/strip} Edited April 15, 2016 by [email protected] (see edit history) Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now