Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

159
Views
Use Product Variants Select in Cart Prestashop

I'm developing a cross sell module that will display products in cart that you can add to cart by clicking the button add to cart. I need to take consideration of product variants (attributes).

I've already find out how to add the add to cart button to the cart page thanks to this code :

<form action="{$urls.pages.cart}" method="post" id="add-to-cart-or-refresh">
        <input type="hidden" name="token" value="{$static_token}">
        <input type="hidden" name="id_product" value="{$product->id}" id="product_page_product_id">
        <span class="remove-from-cart">
            <button class="btn btn-primary add-to-cart" data-button-action="add-to-cart" type="submit"
                {if (!$product->checkQty(1))} disabled {/if}>
                <i class="material-icons float-xs-left">shopping_cart</i>
                {l s="Add to cart" d='Shop.Theme.Actions'}
            </button>
        </span>
    </form>

But what I need now is to update the display price depending about the value chosen with the select option value dropdown set as on my product page and use the attribute id selected in order than when the user click on the add to cart button, it add to cart the product with the good attribute and not the default one

I'm sure that is from js script that the price is updated but I don't really find out which function is in charge of this

This is the select option as asked

      <div class="clearfix product-variants-item">
  <span class="control-label">ATTRIBUTE_GROUP_NAME</span>
          <select class="form-control form-control-select" id="group_ATTRIBUTE_GROUP_ID" data-product-attribute="ATTRIBUTE_GROUP_ID" name="group[ATTRIBUTE_GROUP_ID]">
                  <option value="ATTRIBUTE_ID" title="ATTRIBUTE_NAME" selected="selected">ATTRIBUTE_NAME</option>
              </select>
      </div>
  
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

the solution is not very simple but is achievable, the same way as prestashop works on product page, you have to ajax refresh your content on the attribute change. We developed a complex upselling module on checkout using the same method and it works good. The logical steps are:

-> Select value is changed

-> submit the data via ajax

-> get the fresh and updated data, best choice for me is to render your module view again and get an html as response

-> replace your content with the new html

Another way, not tested because little bit more complex in my opinion, could be to store in javascript all the data about all the variations/combinations and handle the logic there to get the price data you need on every change. A problem with this solution is that the data could be not always updated because stored locally.

I hope my hint helps, I wanted to comment but my ranking is still too low and I have to reply instead.

Simone

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!