The free shipping discount doesn't utilize pricing components. I have a project where I was evaluating pricing components to help track what discounts have been applied to line items, etc. So I attempted to work around this by adding a custom action to all of the free shipping rules. I had struggled with why my custom actions were not sticking until I located the culprit.

commerce_discount_commerce_discount_rule_build looks to find any discount offer that uses the commerce_free_shipping field so it can add the shipping service to the commerce_discount_free_shipping_service action. It does this by looping through all actions on the rule, however for each action that is not commerce_discount_free_shipping_service, it deletes it.

    // Add missing parameter.
    foreach ($rule->actions() as $action) {
      if ($action->getElementName() == 'commerce_discount_free_shipping_service') {
        $action->settings['shipping_service'] = $shipping_service;
      }
      else {
        $action->delete();
      }
    }

Is there a reason that every other action is deleted? I couldn't find anything that made this necessary so I've created a patch (coming shortly) to remove the $action->delete().

Comments

caschbre’s picture

Status: Active » Needs review
StatusFileSize
new481 bytes
joelpittet’s picture

Assigned: caschbre » bojanz

I wonder if @bojanz can shed some light on this one. I can't see why it's deleting actions.

joelpittet’s picture

Status: Needs review » Active
joelpittet’s picture

Status: Active » Needs review

Trying to get the automated tests to pick this patch up...

Status: Needs review » Needs work
joelpittet’s picture

Status: Needs work » Needs review

testbot is being nice, retest

joelpittet’s picture

Assigned: bojanz » jkuma
Status: Needs review » Fixed

I can't see any reason for this to be, thanks for the patch. I've committed it to dev. If it's needed then I guess someone will pipe up and we can add some comments, tests and likely more conditions around the action removal.

It was committed in this issue #1677628: Provide a "Free Shipping" offer type maybe @jkuma can shed some light?

  • joelpittet committed 3f8fd72 on 7.x-1.x authored by caschbre
    Issue #2363331 by caschbre: Allow additional rule actions for free...

Status: Fixed » Closed (fixed)

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