Jump to content

Token Problem When Removing Products from Cart on some Pages


Recommended Posts

Hello friends

I cannot remove products listed in the column cart on the order pages. It works well on product, cms, home and other pages but on the cart, checkout, address, shipping and all the pages with "order.php" steps pages - it does not work.
I discovered that the link on the remove buttons in the cart on the okay pages is as below:

mywebsite.com/cart.php?delete&id_product=10&ipa=0&token=7090b174439d88f7ab7db03f9a7b9b0f

On the order steps pages (cart, checkout, shipping, etc), it only shows the link below:

mywebsite.com/cart.php?delete&id_product=10&ipa=0&token;=

As you can see, the token code is empty. That is why it does not work on these pages. When clicked, it brings the "invalid token" error.

How can I correct it?

Link to comment
Share on other sites

Hello friends

I cannot remove products listed in the column cart on the order pages. It works well on product, cms, home and other pages but on the cart, checkout, address, shipping and all the pages with "order.php" steps pages - it does not work.
I discovered that the link on the remove buttons in the cart on the okay pages is as below:

mywebsite.com/cart.php?delete&id_product=10&ipa=0&token=7090b174439d88f7ab7db03f9a7b9b0f

On the order steps pages (cart, checkout, shipping, etc), it only shows the link below:

mywebsite.com/cart.php?delete&id_product=10&ipa=0&token;=

As you can see, the token code is empty. That is why it does not work on these pages. When clicked, it brings the "invalid token" error.

How can I correct it?


Hello Friends

Can anyone help regarding the above? I still cannot resolve it. Any suggestion is welcomed!

Niyi
Link to comment
Share on other sites

This could be a third-party theme issue. Does it happen when you switch to the default PrestaShop theme?


Thanks Rocky. I found something interesting. The remove button link in the affected pages using the default theme is the same with no token in front, but when clicked, it refreshes or redirects to the cart summary page and the product is removed without any error.
The same thing under my Matrice Theme however results into the "token error" message. The page refreshes or redirects too but bring up the error message instead of the cart summary page.

Other pages do not refresh but the product is removed within the module

Niyi
Link to comment
Share on other sites

  • 1 month later...
  • 5 weeks later...

We have this problem too - well, on one shop ... another shop (on the same server) works fine. Both are v 1.3.7, small differences to the (custom) theme, and a couple of extra modules on the shop that that has the problem. Disabling the extra modules makes no difference.

In our case, it (oddly) seems to be both theme and shop related at present: if we switch the shop that doesn't work to the default PS theme, we still get 'Invalid token'.

If we put the theme that doesn't work into a fresh install of 1.3.7, we still get 'Invalid token' (but the default theme on a default install of PS works fine).

The problem appears to be that $static_token is losing its value in modules/blockcart/blockcart.tpl

It fails on order.php pages because ajax-cart.js specifically doesn't get included on those pages:

At the top of blockcart.tpl:

{if !$order_page}
[removed][removed]
{/if}



and ajax-cart.js seems to compensate on other pages by overlaying its own 'static_token'.

A workaround might be to refresh the $static_token, either at the top of blockcart.tpl just after the script includes and before the opening div, eg:

{php}
$token_refresh = Tools::getToken(false);
$this->assign('static_token', $token_refresh);
{/php}

<!-- MODULE Block cart -->




Or in blockcart.php by adding it to the array in the smartyAssigns() function:

       $smarty->assign(array(
           'products' => $products,
           'customizedDatas' => Product::getAllCustomizedDatas(intval($params['cart']->id)),
           'CUSTOMIZE_FILE' => _CUSTOMIZE_FILE_,
           'CUSTOMIZE_TEXTFIELD' => _CUSTOMIZE_TEXTFIELD_,
           'discounts' => $params['cart']->getDiscounts(false, $usetax),
           'nb_total_products' => intval($nbTotalProducts),
           'shipping_cost' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 5), $currency),
           'show_wrapping' => $wrappingCost > 0 ? true : false,
           'wrapping_cost' => Tools::displayPrice($wrappingCost, $currency),
           'product_total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax, 4), $currency),
           'total' => Tools::displayPrice($params['cart']->getOrderTotal($usetax), $currency),
           'id_carrier' => intval($params['cart']->id_carrier),
           'ajax_allowed' => intval(Configuration::get('PS_BLOCK_CART_AJAX')) == 1 ? true : false,
//  ******  Modded - added next line to fix 'invalid token' errors when removing items from cart on order pages  ******  //
           'static_token' => Tools::getToken(false)
       ));


(If you use the second workaround just above, remember to add the comma on the preceding line to the fix line, otherwise you'll get an error)

Either of the above appears to fix the problem, but please note I haven't had time to test them thoroughly yet, so keep your eye on your shop for unusual behaviour in any other areas which use tokens.

Please post if anyone else has any ideas about what might be the root cause.

  • Like 1
Link to comment
Share on other sites

  • 3 months later...

!!!!!!! I found what is the problem for the deleting products function on order page !!!!!!!!

I don't know how I found that ... :)

In this theme : right colum, left column and footer are in the



You have to exclude them.
It's in footer.tpl find which



is the one corresponding of main_center_column

But after that you will have to do a LOT of css I think ...

I can't give you my files because I already modified all of them (tpl and css)

Link to comment
Share on other sites

  • 11 months later...

SOLVED!!!! for anyone having the same problem, i just managed to find an old post that fixed the problem for me, it didn't have anything to do with tokens in my case. here's what to do!...

 

In file /themes/prestashop/js/cart-summary.js in line 30 after

$(document).ready(function()

{

set

baseDir = 'http://domain.pl/dir/';

 

Where 'http://domain.pl/dir/' i base url of your store :)

Link to comment
Share on other sites

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