Hi,

Here is my scenario:

  • Store default currency = BRL ( R$ )
  • For the sake of this demonstration I applied a discount of 100%
  • The user multi currency is set to AUD

And this is the issue ( take a look at the attached screenshot ):

  • The Subtotal is erroneously set back to the Store default currency as well as it does not get converted to the current multi currency selection
  • The discount is correctly applied upon to the order's converted Subtotal but the discount currency sign is also set to the store default currency instead of the multi currency selection.
  • The order's total is a subtraction between apples and oranges. In this example it should be zero.

Comments

edxxu’s picture

Issue summary: View changes
StatusFileSize
new37.39 KB

Same problem. After installing commerce discount module and setup a rule to give user a free product as discount, the multicurrency seems doesn't work.

skyredwang’s picture

Regarding #1, if the free product is set up with non-default currency, then the total calucaltion works fine; but, if the free product is set up with default currency, then the bug above takes place.

jantoine’s picture

Status: Active » Fixed

Using the latest 1.x-dev release of this module and having correctly configured individual currency price fields, I have a 30% discount on a set number of products that continued to work across the board after enabling the Commerce Multicurrency module. I am using the 1.0-alpha4 version of Commerce Discount. Please re-open if this is still an issue with the module versions I've listed or newer.

Status: Fixed » Closed (fixed)

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

rintoug’s picture

Using the latest, still I am facing this issue. Anyone got this solved? I've tried the latest dev release though.
@skyredwang #1 also not working for me.

RAWDESK’s picture

StatusFileSize
new99.49 KB

Hi,
The drupal discount multicurrency mantra was working like a charm to me until last week i started to experiment with Free product discounts. As my client requested, i setted price to zero for these products.
Result :
- product price 0€ -> discount total 0€ (OK)
- in $ : product price 0$ -> discount total 0€ and also all the rest of commerce total components ! (not OK)
To have this free product selected i had to manually adapt the free product rule though (generated by discount module), in this way that a second condition needed to be fulfilled in an OR relation with the € condition (eg. commerce-order:total > 100$).
Overriding this rule therefore resulted in the same symptom as described in this thread.

My solution was to clone the existing € discount, and adapt the rule afterwards so it takes a $ amount condition instead of €.
Additionally a second (AND) condition was added to both rules : site:commerce-currency = "EUR" (or "USD").

Overview :

free-products-rule-set.png

I would strongly suggest that discount maintainer should provide a multicurrency port into commerce discount. This way the discount admin UI has the ability to select a currency when entering an amount condition to a discount.

loparr’s picture

I can confirm, that discount module does not work with multi currency. Any workaround??

millionleaves’s picture

My solution was similar to #6. Create a discount in the default currency, then duplicate the rule this creates, and modify the duplicate to check the currency of the order, and apply an appropriate discount. You'll need to do this for each currency you support. Also, you won't be able to manage the additional rules through the Discount UI.

AlAngel’s picture

I believe this is an issue with the 'Commerce Discount' module, not 'Commerce Multicurrency' so this issue should probably be moved.

However, I also encountered this issue when using the '% off' discount offer type. The solutions proposed in #6 and #8 helped for '$ off' but not '% off' (specifically, 'Order discount', I'm not using 'Product discount').

I discovered my issue was due to a rule defined in the 'Commerce Discount' module, the commerce_discount_percentage() function (in commerce_discount.rules.inc) was sometimes calculating the discount $discount_amount using the correct figure but the wrong currency (usually, the default currency).

To correct this, I replaced the following lines of code within the the 'commerce_order' switch case in the commerce_discount_percentage() function:

Replace:

// Loop the line items of the order and calculate the total discount.
foreach ($wrapper->commerce_line_items as $line_item_wrapper) {
    // Check if the line item is configured in the discount settings to
    // apply the discount.
    $line_item_type = $line_item_wrapper->getBundle();
    if (in_array($line_item_type, $line_item_types, TRUE)) {
        $line_item_total = commerce_price_wrapper_value($line_item_wrapper, 'commerce_total', TRUE);
        $calculated_discount += $line_item_total['amount'] * $rate;
     }
}

With:

// Store the current currency by default.
$line_item_currency = commerce_multicurrency_get_user_currency_code();

// Loop the line items of the order and calculate the total discount.
foreach ($wrapper->commerce_line_items as $line_item_wrapper) {
    // Check if the line item is configured in the discount settings to
    // apply the discount.
    $line_item_type = $line_item_wrapper->getBundle();
    if (in_array($line_item_type, $line_item_types, TRUE)) {
        $line_item_total = commerce_price_wrapper_value($line_item_wrapper, 'commerce_total', TRUE);
        $calculated_discount += $line_item_total['amount'] * $rate;
        // Update variable with the line item's currency, probably unnecessary
        // as this should be the current currency but let's double check.
        $line_item_currency = $line_item_total['currency_code'];
    }
}

And replace:

$discount_amount = array(
    'amount' => $calculated_discount * -1,
    'currency_code' => $wrapper->commerce_order_total->currency_code->value(),
);

With:

// Check discounted currency matches current currency.
if($wrapper->commerce_order_total->currency_code->value() == $line_item_currency){
    $discount_amount = array(
        'amount' => $calculated_discount * -1,
        'currency_code' => $wrapper->commerce_order_total->currency_code->value(),
    );
}else{
    // If not, update currency code.
    $discount_amount = array(
        'amount' => $calculated_discount * -1,
        'currency_code' => $line_item_currency,
    );
}

The changes are:

* Create $line_item_currency to store the line item's currency.
* Use this to check if the $discount_amount array has the same currency code...if not, update it.

(I haven't created a patch because I believe more work is needed for a solid solution)

berenddeboer’s picture

I had the same problem with a free product. I believe the error is actually in the commerce_discount module: it does not call the proper methods to calculate the price I think.

See attached patch, that solved all problems for me.