Jump to content

user logged cannot add to cart


stek.

Recommended Posts

Hi guys,

I'm using Prestashop 1.7.5.1 with Pos Colora2 Theme. My issue is about the cart. In particular, if user is logged he can't add products to cart, with the exception of product page where it works.

The home page has a module called POS Category Tab Slider that it shows best products. This anomaly is only present on user side, not guest. But I haven't any error.

Do you think it's prestashop or module issue?

Thanks

 

Link to comment
Share on other sites

Hello:

It should be a module issue, probably with the add to cart button rendering. Anyway, there is an ajax request that is triggered when you click on add to cart button. Inspect that request on your browser developer console with Prestashop debug mode enabled. Yhis will give you a hint about any possible related errors. If not, you should see a JS error in your browser console that could be another cause of this issue.

Regards

Link to comment
Share on other sites

Hi Rolige,

thanks for your answer. You had right! It was a module issue. Reading your answer, it had noticed that when I was logged in the cart ajax request returned 302. 

Searching on web, I found that the issue was the token inside the button-cart.tpl. I had modified  the static string with {$static_token} and so now it's working.

 

I hope that this is useful for anyone.

Stek  

Edited by stek. (see edit history)
  • Thanks 2
Link to comment
Share on other sites

  • 7 months later...
On 4/16/2019 at 3:53 PM, stek. said:

Hi Rolige,

thanks for your answer. You had right! It was a module issue. Reading your answer, it had noticed that when I was logged in the cart ajax request returned 302. 

Searching on web, I found that the issue was the token inside the button-cart.tpl. I had modified  the static string with {$static_token} and so now it's working.

 

I hope that this is useful for anyone.

Stek  

You saved me lot of time! In my case, I had in form for add to cart this:
 

<form action="{$urls.pages.cart}" method="post" class="hiaddtocart">
                                <input type="hidden" name="token" value="{$token}">
                                <input type="hidden" name="id_product" value="{$product.id}" class="product_page_product_id">
                                <input type="hidden" name="id_customization" value="0" class="product_customization_id">
                                <button class="btn btn-primary fa-shopping-basket" {if ($product.quantity == 0)}disabled{/if} data-button-action="add-to-cart" type="submit">
                                    Add to cart
                                </button>
                            </form>

And just replaced $token with $static_token

 

Thank you very much stek. !

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

  • 3 months later...
On 11/19/2019 at 11:13 PM, haunter said:

You saved me lot of time! In my case, I had in form for add to cart this:
 


<form action="{$urls.pages.cart}" method="post" class="hiaddtocart">
                                <input type="hidden" name="token" value="{$token}">
                                <input type="hidden" name="id_product" value="{$product.id}" class="product_page_product_id">
                                <input type="hidden" name="id_customization" value="0" class="product_customization_id">
                                <button class="btn btn-primary fa-shopping-basket" {if ($product.quantity == 0)}disabled{/if} data-button-action="add-to-cart" type="submit">
                                    Add to cart
                                </button>
                            </form>

And just replaced $token with $static_token

 

Thank you very much stek. !

Where is the location of the  button-cart.tpl  ?

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