Multiple add to cart buttons on product page

  • Posts: 20
  • Thank you received: 0
7 years 9 months ago #275259

Hi,
I have a high product page and would like to add a second add to cart button on the bottom of the page so the user doesn't have to scroll back up once he as reached the bottom.
I am using the quantity field (with + and -) to add several products to the cart.

The issue:
Both add to cart buttons always add the number of products set in the second quantity field. This makes the quantity field on the first add to cart button unusable and confusing for the user.

The desired behaviour :
Each add to cart button should add the number of products set in its closest quantity field.

Can achieve this behaviour with template overrides?

Last edit: 7 years 9 months ago by web-tiki.

Please Log in or Create an account to join the conversation.

  • Posts: 83799
  • Thank you received: 13571
  • MODERATOR
7 years 9 months ago #275261

Hi,

The whole product page is inside a HTML "form" tag.
When you click on an add to cart button, the system automatically takes all the inputs inside that form and submits it.
If two inputs have the same name, the server will keep only the last one. So the first one will be lost.
That's why you get that problem with your customization.
What you should do is change the name of the second input and change the onclick event of the second add to cart in order to copy the value of the second input to the value of the first one before running the standard add to cart procedure.
So it is totally possible to do it with template overrides.

The following user(s) said Thank You: web-tiki

Please Log in or Create an account to join the conversation.

  • Posts: 20
  • Thank you received: 0
7 years 9 months ago #275365

Hi Nicolas and Thx for the info,

I finaly decided to make both quantity fields work together so when one is changed, the other quantity field is updated.
This way no need to change the name of the input.

Please Log in or Create an account to join the conversation.

Time to create page: 0.038 seconds
Powered by Kunena Forum