Prestashop Custom / Estimated Product Price

I have a website for printing banners. I want the client to enter the width and height, and using my own table, I calculate and display the price. Now I want to move the estimated price to the Basket and from there until the order is created. I checked the preashop tables for the cart, but it stores the product identifiers and joins the product tables to get prices. Anyway, to reach my requirements?

+7
prestashop
source share
1 answer

This function is not available by default in prestashop, and I do not know any module that can do this without overloading the kernel functionality. I provide you only the theory and some file links for you. Please, try.

Consider the following general assumptions:

a) Measuring unit - inch.

b) The price per inch is $ 5

c) You will also need a pricing formula, and for this example, this means

finalPrice = width x height x 5 //width and height are formula variables 

Now for prestashop you can follow these steps:

1) Update the cart and add three fields, width, height and final_price. (The number of fields can vary according to your formula variables).

2) Overload the basket class and add properties for width, height and final_price. You also need to override the method that extracts all products from the basket and checks if the product in the basket has a custom price, width and height. Also, all taxes and shipping costs may apply.

3) If you use the ajax add to cart function, you need to slightly modify the blockcart module. You may need to modify ajax-cart.js to get the width, height and final price for sending to the cart controller. Also, blockcart-json.tpl may require some changes, as this file is used to fill the contents of the cart block. You may also need to modify the blockcart.tpl file, where you can show the width and height, etc. In the block map. This way you can show the variables in the blockcart.

4) Now the next step is actually adding the product to the basket. The data is sent to the CartController, so you need to redefine it and get the width, height and final price from the published data. You will need to place appropriate checks if the width or height is available, as well as the final price or not, in order to determine the product of the user price.

5) You will need to override the OrderController to populate the list of products in the basket with width, height and final price.

6) In all of the above theory, we added the product to the basket and the completed page of the block map and basket with data on width, height and final price. Now the next step completes the order. To do this, you will need to work with the Order class, the order controller and the cart class. and order_product. In the product table for the product, add the same fields as the cart_products table for width, height, and final_price. Then change the order class and add these properties to order the class.

7) You need to override the PaymentModule class and make changes to the validateOrder method. This method processes your last step in ordering the steps, saves the order, sends an email to the client and, if enabled, to the site administrator (s). So here you will need to add the width, height and final price information to the insert code of the order code db. You will also need to provide these variables to the email templates so that the customer can get the width, height and final price of the product in the email.

8) You will also need to change the order history section so that customers can see all these details in their order history.

9) You will need to make changes to the administratorโ€™s order controller to display this data in the order viewing section for the administrator.

10) And finally (not final: P), you will need to make changes to the generation of the invoice in pdf format so that the width, height and final price in the pdf account are also displayed.

Note. The above theory from my experience is similar to the function in prestashop and may or may not work for you according to your requirements .

Try it and I hope you earn it :) ..

Luck...

+3
source share

All Articles