I'm having trouble grokking the price handler system as it pertains to the transition from carts to orders during checkout. Part of this is the documentation on Ubercart.org merely lists out possible types without explaining when the types will be used or how to understand them in relation to this transition. Then also I see that the "order_product" type is being used to alter prices in the checkout form validate handler... what I don't understand is how this will then pull in any appropriate product discounts to the order. In fact, it doesn't seem to be doing this at all. I changed this to "cart_item" and had some progress until I realized that after the order is submitted the prices are off again... as in undiscounted. (The same proved true even after I reverted that to "order_product.")

So... I have no clue what's going on. Have you tested discounts at all using uc_discount to understand why product discounts might not be preserved through checkout?

This is related to: #597992: Discount not reflected on total order (FIXED for Trigger: Calculate order discounts)

Comments

melon’s picture

Title: Price handler problems with carts becoming orders and already saved orders » Price handler problems with carts becoming orders

Subscribing as I'm struggling with the exact same problem.
It worked fine in 2.0-rc6 with uc_discount but it doesn't since 2.0.

Any followups? Would be happy to test patches against both ubercart core or uc_discounts.

melon’s picture

Title: Price handler problems with carts becoming orders » Price handler problems with carts becoming orders and already saved orders

In the meantime I peeked in the code and as I see the uc_cart_checkout_form_validate() tries to match the altered prices with originals and if they differ, store the altered price in $product->data. This way it would store both the historical data of the original and the discounted price.
However the comparison logic seems wrong to me as it pulls the original price not the altered which is of course identical to itself. Additionally I found that this altered_price stored in the uc_order_products table is never used again.

Additionally, across all the order view/edit functions only on-the-fly altered prices are shown from saved orders which is completely the opposite of the supposed original idea IMO.
Once an order is stored in the database it should never be altered anymore since discount rules can change over time.

I modified uc_cart.pages.inc, uc_order.module and uc_order.order_pane.inc to fit the needs of my client's store.
However I'd rather not post patches here because I guess this issue needs a major revision and I bet my fix would only work in that specific setup.

melon’s picture

Title: Price handler problems with carts becoming orders » Price handler problems with carts becoming orders and already saved orders

Any updates on this?
Bumping this up... let's hope this gets under someone's radar...

longwave’s picture

Status: Active » Closed (duplicate)