Jump to content

Smarty Js variables not stored


Duskfall

Recommended Posts

Hello i am developing a cart module extending the default block cart module.

I add extra variables in smarty template file /modules/mymodule/sometemplate.tpl

and although after a clear cache the variables are loaded properly in header like so :

var hasDeliveryAddress = false;

 

When i reload the page the variable doesn't load up at all, along with my other variables. I tried for hours to find why but didn't succeed. Any enlightment on this?

 

All these variables from block cart dont load after second reload since template is cached.

 

{strip}
{addJsDef CUSTOMIZE_TEXTFIELD=$CUSTOMIZE_TEXTFIELD}
{addJsDef img_dir=$img_dir|escape:'quotes':'UTF-8'}
{addJsDef generated_date=$smarty.now|intval}
{addJsDef ajax_allowed=$ajax_allowed|boolval}
{addJsDef hasDeliveryAddress=(isset($cart->id_address_delivery) && $cart->id_address_delivery)}
{addJsDefL name=customizationIdMessage}{l s='Customization #' js=1}{/addJsDefL}
{addJsDefL name=removingLinkText}{l s='remove this product from my cart' js=1}{/addJsDefL}
{addJsDefL name=freeShippingTranslation}{l s='Free shipping!' js=1}{/addJsDefL}
{addJsDefL name=freeProductTranslation}{l s='Free!' js=1}{/addJsDefL}
{addJsDefL name=delete_txt}{l s='Delete' js=1}{/addJsDefL}
{addJsDefL name=toBeDetermined}{l s='To be determined' js=1}{/addJsDefL}
{addJsDefL name=txtProduct}{l s='product' js=1}{/addJsDefL}
{addJsDefL name=txtProducts}{l s='products' js=1}{/addJsDefL}
{/strip}

Edited by Duskfall (see edit history)
Link to comment
Share on other sites

Extra info after ~ 10 hours of try and error:

I have only seen the products to be updated when module is attached in displayTop hook.

 

Mine is attached in displayInsideMenu (block top cart) and header.

If i attach it in displayTop too, i can see the difference in the two carts.

 

Steps to reproduce:

1) have cart block in header, displayTop and displayInsideMenu  custom hook which is inside blocktopmenu template like so :

{Hook::exec('displayInsideMenu')}

 

2) inspect the two carts by removing display none in class="cart_block block exclusive" in html.

 

3) both product lists are same

 

4) add an extra item ( ajax cart enabled)

 

5) refresh page

 

6) displayTop cart has more products

Edited by Duskfall (see edit history)
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...