Jump to content

Block Cart - using the order step variable


shroom

Recommended Posts

Hello,

 

I'm looking to slightly modify the block cart, and I'm trying to use the variable that stores the order step.

 

Finding it was easy [ Tools::getValue('step') ] but as ajax is activated, I have to alter 2 tpl files : blockcart.tpl et blockcart-json.tpl.

 

While I have no issue getting the proper value inside the first one, I can't use it on the json version as it always returns an empty string.

Any solution on how to use that variable in the ajax template ?

Link to comment
Share on other sites

i think you have to edit the blockcart module, specifically the blockcart.php file. There is a function called smartyAssigns, where the template variables are added.

 

you need to get the step value using the Tools::getValue('step'),and then assign the value to a smarty variable.

 

then you would revise the templates to use that new variable.

Link to comment
Share on other sites

5-page checkout, using the standard theme, slightly modified but nothing that should break that module (PS v1.4.6.2).

I also tested on a fresh installation (v1.4.6.2) just to be sure : same results with the variable and your tip.

 

I looked at the code several times, can't really understand why it works for the standard version but not for the ajax one...

 

I just replaced this in the json tpl file :

"shippingCost": "{$shipping_cost|html_entity_decode:2:'UTF-8'}",

with :

"shippingCost": "{(int)(Tools::getValue('step'))|html_entity_decode:2:'UTF-8'}",

 

This returns 0, because of the (int). But the variable is pretty much empty.

Link to comment
Share on other sites

you are trying to use the Tools class from within the template, which is a no-no.

Aside from my issue, shouldn't this apply to the Cart class too, which is also used within the standard template ?

 

 

My instructions called for placing the value in a smarty variable, and then using the variable in the template.

Adding something like this to the proper hooks, right ?

$smarty->assign('order_step', (int)(Tools::getValue('step')));

Which gives :

public function hookAjaxCall($params)
{
if (Configuration::get('PS_CATALOG_MODE'))
return;

global $smarty;
$smarty->assign('order_step', (int)(Tools::getValue('step')));
$this->smartyAssigns($smarty, $params);
$res = $this->display(__FILE__, 'blockcart-json.tpl');
return $res;
}

 

But this doesn't work : the variable is properly set, but it isn't being updated as we go through the order steps, tested on a fresh PS install.

This works for the standard version though.

Link to comment
Share on other sites

question would be what calls hookAjaxCall ? I suspect that hook is not getting called as you are expecting it to be called.

 

As for the Cart class usage, are you referring to the following code?

{assign var='blockcart_cart_flag' value='Cart::ONLY_WRAPPING'|constant}

 

I can understand why they are doing this, but no the best practice is not to do this. They should have assigned the constant to a smarty variable.

Link to comment
Share on other sites

question would be what calls hookAjaxCall ? I suspect that hook is not getting called as you are expecting it to be called.

That's the function that calls the ajax template.

So, if that's not the best place to put that instruction, I don't know where to add it.

Also the variable is properly recognized. The only difference between the standard and the ajax templates is that the variable isn't being updated on the ajax template.

Link to comment
Share on other sites

  • 1 month later...

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...