Copy of discussion http://www.drupalcommerce.org/discussions/4113/discount-amount-cart-does...

Post 1:
==================================
I try to add simple discount: 7% if total sum is grater than $60
At admin/commerce/config/taxes/types i have new type: discount
At admin/commerce/config/taxes i created new tax rate Discount 7% (component)
In this component i created condition “Data comparsion” and seleced option “commerce-line-item:order:commerce-order-total:amount”
And lets test it: order for total sum $58.88: http://i.imgur.com/FIfVe.png Looks ok, no discount.
But when i went back to “view cart” and click on checkout i saw the same product list with discount 7% http://i.imgur.com/QDghA.png It happens randomly. Sometimes the discount appears sometimes does not appear. I did not change anything in rules settings.

Another strange thing: total sum is $67.88 http://i.imgur.com/mp7AI.png but in debugging variable commerce_order_total this value is set to 63.13 so after discount. In previous case (58.88) this value was set to 58.88 so before discount calculation.

I was reading http://www.drupalcommerce.org/discussions/1123/discount-amount-cart but this didn’t help me.

Discount rule settings: http://i.imgur.com/q2ONU.png http://i.imgur.com/Au0qj.png

List of contrib modules: http://i.imgur.com/5Sp4h.png
Drupal 7.14
Commerce 7.x-1.3

==================================

Post 2:

I tried to use hook_commerce_tax_type_calculate_rates and i found this:
My case:
1. Cart: Total $63.38 http://imgur.com/BtV5W
2. Checkout: http://i.imgur.com/jGVVn.png - Discount 7% work OK (no title, but this is no big problem)
3. Go back to Cart and remove one product for $4.50 http://i.imgur.com/gfTno.png
4. Discount 7% is still in summary http://i.imgur.com/qcdAB.png
5. commerce_cart_order_load($user->uid) object still has information about discount http://i.imgur.com/IS4BE.png
6. Now when i refresh checkout page discount disappear http://i.imgur.com/9ZMHz.png and commerce_cart_order_load($user->uid) object works ok http://i.imgur.com/BSfG9.png

So problem is in function commerce_cart_order_load - this function do not refresh commerce_order_total attribute when user change something in cart and click on Checkout button.

Now i used custom code and custom module: http://pastebin.com/75JCuR7f

Maybe the same problem is when i try use rules?
===================================

Comments

rszrama’s picture

Component: Tax » Other
Status: Active » Closed (duplicate)

Let's keep the discussion over there.

grzegorz.bartman’s picture