Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
uc_order_condition_total() checks $order->total.
uc_order_condition_subtotal() checks line item 'subtotal'.
But these 2 values may not be calculated yet at the time conditions are evaluated.
Conditions should calculate these values themselves when they are not available.
Comment | File | Size | Author |
---|---|---|---|
#6 | 2885761-6.patch | 1.2 KB | TR |
| |||
#2 | conditions_total_subtotal_calculate-2885761-2.patch | 901 bytes | anrikun |
|
Comments
Comment #2
anrikun CreditAttribution: anrikun commentedHere's a patch.
Comment #3
TR CreditAttribution: TR commentedUnder what circumstances does this condition return the wrong answer?
Comment #4
anrikun CreditAttribution: anrikun commentedWhen shipping quotes get calculated on op prepare when order has just been created from cart items. At that point, total is always 0 and subtotal is not available yet.
Comment #5
TR CreditAttribution: TR commentedAdded Rules component.
Comment #6
TR CreditAttribution: TR commentedSo why not always use uc_order_total() to get the total/subtotal in these actions, rather than using it only if our first choice fails?
I would much rather always go through a function call, to make sure all the hooks get invoked etc., rather than trying to access order variables directly and trying to calculate the total/subtotal in our own way in the action.
Does this patch work properly and solve the problem?