1

I am trying to write a rule for an existing order. Order has a zero total due to (Commerce) discount, e.g.: Widget $3.00 Discount -$3.00

For the condition, I'd like to check if a specific discount is applied. For the action, I'd like to:

  1. delete the discount line item (-$3.00)
  2. add (specific) existing check payment method with the total before discount ($3.00)
  3. Perform "cash" / cleared operation on the payment method.

So far I only managed to do step 1. by using the commerce_coupon_rules_order_has_specific_coupon.patch that looks for a specific coupon - which works but ideally condition that looks for a discount would be preferable. I wasn't able to do any of step 2 and 3 operations.

Here is the export of the rule I tried:

{ "commerce_checkout_update_the_order_payment_on_admin_orders" : {
    "LABEL" : "Update the order payment on Admin orders",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "Commerce Checkout" ],
    "REQUIRES" : [ "commerce_coupon", "rules", "entity" ],
    "ON" : { "commerce_order_update" : [] },
    "IF" : [
      { "commerce_coupon_discount_coupon_codes_exist_on_order" : {
          "commerce_order" : [ "commerce_order" ],
          "commerce_discount" : "discount_admin_only_prepaid_by_check"
        }
      }
    ],
    "DO" : [
      { "mail" : {
          "to" : "user@example.com",
          "subject" : "test",
          "message" : "test",
          "language" : [ "" ]
        }
      },
      { "LOOP" : {
          "USING" : { "list" : [ "commerce-order:commerce-line-items" ] },
          "ITEM" : { "prepaid_by_check" : "prepaid_by_check" },
          "DO" : [
            { "component_rules_remove_prepaid_by_check_line_item" : {
                "prepaid_by_check" : "prepaid_by_check",
                "order" : [ "commerce-order" ]
              }
            }
          ]
        }
      }
    ]
  }
}
  • Hi, I think that the question could lead to opinionated answers as it's worded. It would help if you could be more specific about what you have already tried. You could export the rule that you're working on or how you are thinking about doing it from the user interface. – mradcliffe Nov 19 '19 at 15:11
  • Thanks for the advice. Great idea. I made an edit. – David Nov 19 '19 at 15:38

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.