I recently updated to the latest dev version (8/16/11) and my custom taxes that were configured to be discounts are no longer working.

In the previous versions i could set a negative tax rate. e.g. -0.2 for %20 discount. Now it just adds 20% regardless of the (-) preceding the amount.

I hadn't updated commerce for a couple weeks so I can't be sure when exactly this problem started, but my guess is that this problem was introduced with the tax rounding features.

Comments

rszrama’s picture

Status: Active » Fixed

Ahh, you're right. In the event that there was no decimal in a tax amount to round off (or in your case a discount amount, such as an even $10 off), I was returning the amount after running abs() on it without resetting the negative sign like I do at the end of the function. The fix was easy, but on a side note you probably don't need to do this any more. As of a couple releases ago, you can now select a price component type in a product pricing rule so you can specify in a "Multiply the unit price by some amount" action the "Discount" price component type and have the adjustment show up as such in the order total display.

Commit: http://drupalcode.org/project/commerce.git/commitdiff/3e4849a

bradhawkins’s picture

Thanks Ryan, that solves it!

I did try both as a "Tax Rate" and as a "Discount" when I was initially setting things up, however I settled on tax rate for a couple of reasons:

• as a tax rate I can give it a name that shows up in the subtotal. e.g. "3 or more" discount for buying more than 3 items and "5 or more" for buying 5, etc. Using "Discount" always shows up as "Discount" regardless and might be confusing for the customer (since we'll have a tiered pricing system).

• as a tax rate it can adjust the product prices dynamically before checkout. So if someone adds 3 items to their cart they see the discount applied to all items in the store, if they have 5 it increases the discount further hopefully inciting them to add more items to their cart. : )

I'm going off memory here, so maybe things have changed since I did my initial setup. Regardless you're right that it could work as a "Discount", but I just wanted to give you an idea of why someone might still want to use negative tax rate instead.

Thanks again for the commit!

rszrama’s picture

Yeah, your recourse would be to define a new price component type in a module (there is no UI right now) with the name you want. You could then select it from the action. I did fix a longstanding bug for RC1 that solves your second issue; price calculation will always point to the shopping cart order if available, so you should be able to show the discount in advance on product pages.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.