0

I'm using Drupal Commerce and when I use some methods (the commerce_fees ones) I have this error :

Warning : Invalid argument supplied for foreach() dans commerce_discount_usage_order_discounts() (ligne 1083 dans /var/www/clients/client1/web84/web/sites/all/modules/contrib/commerce_discount/commerce_discount.module).

How can I avoid that ? The error comes from a contrib module, I can't edit it. And the values that I give to the functions are good, it's just the order and I get it like this :

$order = commerce_order_load($order_id);

Anyone know how to fix this ? Or maybe hide the warnings ?

Spialdor
  • 1,475
  • 5
  • 20
  • 46
  • Are you using the latest version of the module? Have you searched the [module issue queue](https://www.drupal.org/project/issues/commerce_discount?status=All&categories=All)? Have you debugged to see what the actual argument that the function is getting actually is (it expects an order object)? – 2pha Jul 24 '18 at 10:59
  • Yes i'm using the last version, I don't know why it's doing this because the expected object is the one I send – Spialdor Jul 24 '18 at 11:50
  • Weird that your error is reporting the function `commerce_discount_usage_order_discounts()` line 1083. [When I look at line 1083 of the latest beta version](https://cgit.drupalcode.org/commerce_discount/tree/commerce_discount.module?id=7.x-1.0-beta5#n1083), it is the function `commerce_discount_usage_get_usage_by_mail` – 2pha Jul 24 '18 at 13:59
  • The warnings are not show if I comment this line : $line_item = commerce_fees_line_item_new($fee, $base_rate, $order->order_id); – Spialdor Jul 24 '18 at 14:03
  • well, commenting out a line wont help you. as it probably wont calculate the discount – 2pha Jul 24 '18 at 14:04
  • Yes but now I know that the error comes from this function : commerce_fees_line_item_new – Spialdor Jul 24 '18 at 14:05
  • It looks to me like you are not using the latest version (7.x-1.0-beta5). It seems to me like you are using (7.x-1.0-alpha8). I can tell this because in Alpha8, line 1083 is a `foreach()` in the function `commerce_discount_usage_order_discounts`. take a look for yourself [HERE](https://cgit.drupalcode.org/commerce_discount/tree/commerce_discount.module?id=7.x-1.0-alpha8#n1083) – 2pha Jul 24 '18 at 14:07

1 Answers1

1

You are using an old version of the module. (Alpha8) by the looks of it HERE.

Update the module to a more recent version, currently (7.x-1.0-beta5).

If you are still getting the error, report it to the module issue queue HERE

2pha
  • 9,798
  • 2
  • 29
  • 43