php - how to add to cart a product with a value multiplied by some amount.? ← (PHP, JavaScript, HTML)

one text

Solution:

Locate the product.tpl file in your theme folder. There is an <input id="quantity_wanted"> element. You need to update this value according to user input of the product width and height.

Adding to cart will be handled by Prestashop, as it sends {id_product, quantity, id_product_attribute, ...} to the PHP controller, where quantity is value of "quantity_wanted" input.

So, add two HTML <input> elements for width and height and process these values using Javascript, which will change "quantity_wanted" input value.

Also think of: providing this functionality inside a module to avoid changing Prestashop core code, storing width and height of each added product, as you will need this information to prepare customer order.

Source