Answer the question
In order to leave comments, you need to log in
Cost calculator on Opencart - how to transfer the price and parameters to the cart?
There is a ready-made calculator for calculating the cost of products written in javascript and a site on opencart. The task was to embed the calculator on the product page, with further transfer of the calculation results to the basket and ordering.
What I did: in the admin panel, I added a code with a calculator to the product description. In product.tpl, I commented out unnecessary lines - only the image of the product and the calculator are displayed on the page. Calculator counts. There are 10 fields of order parameters (it can change for other products), the calculator is quite complicated, it makes several parallel calculations and selects the lowest price - there is no option to implement dynamic price changes with built-in opencart capabilities.
What is the result: there is a field with the result. I can’t link it to the “Buy” button in any way so that I add this particular estimated price to the cart - it loads the price from the admin panel all the time.
How to do it? Plus is also formed on the basis of filling out the forms of the calculator - a text explanation for the order, such as material - such, area - such, it is better to make a product from one element or from two - all this data must also be transferred to the basket.
Answer the question
In order to leave comments, you need to log in
I would use product options for this.
The options allow you to add a textarea (for a text description) and some field for the total price (for example, input[type=text]). In the cart, hide the price of the product, instead display the value of the product option (input).
You can also use a ready-made calculator for calculating the quantity and cost of an order both in the product card and at the category level Mega calculator for Opencart 2.x
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question