We can create line items not only for orders, but hook_commerce_shipping_method_collect_rates() executes on every shipping rates collect event. I've provided additional checks for commerce_discount's implementation

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

id.tarzanych’s picture

joelpittet’s picture

Status: Needs review » Needs work
+++ b/commerce_discount.module
@@ -131,8 +131,10 @@ function commerce_discount_remove_discount_components($price_wrapper) {
+  if (!empty($order->order_id) || (empty($order->order_id) && !empty($order->is_new))) {
...
 

Is there a case when this is false and the $order is not just empty itself?

id.tarzanych’s picture

@joelpittet
Exactly. Commerce RMA module sends $order object without any parameters except one or two fields data

joelpittet’s picture

@id.tarzanych can RMA just pass the $order along with it?

id.tarzanych’s picture

@joelpittet
Well, it should do that.
But seems that we should wait till Commerce RMA developers change their code to make it compatible with Commerce Coupon 2.x/Commerce Discount or provide additional checks as I did in this patch.

Drupal 8 doesn't have such problem because we can easily check what Entity type object belongs to

joelpittet’s picture

Project: Commerce Discount » Commerce Return Merchandise Authorization

Moving over to Commerce Return Merchandise Authorization to deal with #4