glutenhelper Posted August 24, 2005 Share Posted August 24, 2005 Problem topic: wrong amount shown in discounted prices in checkout and confirmation pages...and of course in the total for billing.. I made a mod to allow the webmaster to have a 10% discount on all products...except when he puts an individual product on sale, then that bulk discount is ignored. What I did was intercept the final_price of the product in the shopping_cart class and if the product was not on sale and more than 9 were ordered, I would multiply by .90 to get the 10% discount on each item. Worked perfect except for the final display. When the shopping cart, confirmation page, and totals modules get the price it rounds it wrong. An example on the page would look like this $39.60 ---> Individual price*10 Bulk Discount 3.564 ----> This is the new price per item at 10% discount (this number was brought out to 6 decimals and it still came out wrong in currencies.) $35.60 ---> This is the actual amount the currency class outputs and is wrong 35.64 ---> this is the proper amount I display by multiplying by the Quantity. I formatted the number to be 4 decimals and even tried 5 and 6 decimal places, but it stayed wrong throughout. The data entered into the order table is correct though as far as the price per item, but the totals are wrong too. I have narrowed it down the the currency classes and the rounding method. Every other type of discount and multiplier works well except when I intercept the price to change it to a 10% off. I have tried string, number_format, float, and a few other crazy ideas but none of them work. It is as if the currency class just hates my price and drops off the last few decimals anyway. I can multiply the number times the quantity and it is perfect, but when the currency class does it, it is off by 4 to 20 cents depending on the item. I know it has something to do with my formatting of the number. The webmaster is willing to exchange mods to get this fixed. =========You can test by going to http://www.glutenfreemall.com/catalog/index.php and selecting an item that is not on sale and ordering more than 9 of them. I have set it up to display the per item followed by the currency class price then by the proper price it should be. (as in my example above) You can email me at [email protected] Thanks for any help. We can pay for the fix too. Link to comment Share on other sites More sharing options...
user99999999 Posted August 24, 2005 Share Posted August 24, 2005 I guess you would have to post some code and we can take a look. Link to comment Share on other sites More sharing options...
glutenhelper Posted August 24, 2005 Author Share Posted August 24, 2005 I guess you would have to post some code and we can take a look. <{POST_SNAPBACK}> I will post some code, but the code is just standard..here goes When the price is intercepted I do this...(in the shopping cart class, in two places) if ($qty > 9) {$products_price = ($products_price*.90);} This bascially says it the quantity is greater than 9, take 10% off. There are numberous ways to do this such as multiplying by 10% and then subtracting, but they all mathematically get the same price. To this equation I have added 'round' tep_round', number_format, etc..and the numbers look good when displayed but not when they enter the currency. The currency class is located in the classes folder. It is accessed on the confirm, orders, and shipping via a code like this.... $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']) For those reading this that do not know the code well, the '$roducts_price' in the shopping cart class goes into an array and is used as $products['final_price'] and that amount is used throughout the checkoput process. So, if anyone knows why the number is not going to the currency correctly, remember I have dragged it out to 6 decimal places, please let me know. ------------------------------------------------------------ The above module can easily be institued with an if/else statement in the specials code fo the shopping cart class. Basically saying 'if not on special and quantity more than 9, discount 10%'. ------------------------------------------------------------ Someone out there must have had a problem before with this/ The webmaster can pay for a quick fix or do some custom mod trades..... To reply to the second post here asking for code, I am not sure what code you would need. This is a simple intercept of the final_price that changes its value by 10%. The example both on the site and listed in the first post show the results of it. There really is no other code unless you need me to post the entire currency class, but we have not modified it at all. Thanks Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 24, 2005 Share Posted August 24, 2005 Can't you use: $currencies->display_price($products[$i]['final_price'] * $products[$i]['quantity'], tep_get_tax_rate($products[$i]['tax_class_id']), 1) and in the classes/shopping_cart.php: $this->total += tep_add_tax($products_price * $qty, $products_tax); instead of: $this->total += tep_add_tax($products_price, $products_tax) * $qty; Link to comment Share on other sites More sharing options...
glutenhelper Posted August 24, 2005 Author Share Posted August 24, 2005 Can't you use: $currencies->display_price($products[$i]['final_price'] * $products[$i]['quantity'], tep_get_tax_rate($products[$i]['tax_class_id']), 1) and in the classes/shopping_cart.php: ? ? ? ? ?$this->total += tep_add_tax($products_price * $qty, $products_tax); instead of: ? ? ? ? ?$this->total += tep_add_tax($products_price, $products_tax) * $qty; <{POST_SNAPBACK}> The shopping cart and the currency classes all use the individual price of an item and inside the currency is where is multiplies the individual item times the quantity. If you rewrite the script to only allow this discount and set umber of items nothing else would work right. And leaving it as it is the currency would then take th enew product amount (already times the quantity) and then multiply it again. It has to be something small and obvious to someone about this problem. IT seems to need to be formatted a certain way before it goes into the currency and totals or it blows it self up.... thanks for the go at it though. Link to comment Share on other sites More sharing options...
Jan Zonjee Posted August 24, 2005 Share Posted August 24, 2005 It has to be something small and obvious to someone about this problem. IT seems to need to be formatted a certain way before it goes into the currency and totals or it blows it self up.... I happened to stumble across this same issue yesterday and this is what seemed to solve it. I don't see the problem you seem to have:What happens is that currencies->display_price first rounds the price to two decimals, then calculates tax and then it is multiplied by quantity. Problem solved if you first do the multiplying by quantity. But if you think there must be a better solution... good luck. Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.