Jump to content

Tracking Price * Quantity. Please help me.


Recommended Posts

I am making a module that enables a certain product to use fractions as acceptable quantity of order. My approach was to keep it clean from the database and let the classes and controllers handle it. for example an order of 2.17 would be 2170 in the database and the classes will just compute differently for this specific product and report the fractional form to the ui. Now my problem is the following. I managed to get it working on the cart both view and saved to the db and also after the cart transforms into an order, the quantity is showed and stored correctly. However the Price total is always just truncating the fractional representation to the nearest integer and multiply. For example ordering 2.17 will total to the rice of 2, ignoring the 17. I went on a trace witch hunt trying to find that piece of code that does these calculation but to no avail. All I need is a few pointers on where to look. thank you for reading and I hope any here can help me.




To be more technical. The quantity in ps_cart_product and the quantity in ps_order_detail are correct to 2170 but the total price in ps_order_detail is just base price * 2. this is why I am assuming it truncates 2.17 to 2 then multiply. I tried to look and look but my humble skills fails me. Please help me with pointers on where to look or describe the technical process of a cart product order turning into an order_detail.


thank you so much!

Edited by lophie (see edit history)
Link to comment
Share on other sites

There are several modules that claim that that they can handle fractions but I am not sure how they do it. See for example





Early rounding in Prestashop used to be indeed a major problem that caused VAT calculation errors. It should have been solved with In that version there should be an option to set when rounding should happen (I haven't checked it). So it depends on what version you use.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...