1
Answers
Vote up!
0
Vote down!

Creating Rule to Add/Remove a conditional fee in cart

We charge a $50 setup fee to run made to order moulding that totals less than $250. I have managed to get it to add on the "after adding a product to the cart action as seen here:

    { "rules_setup_fee" : {
    "LABEL" : "Setup Fee",
    "PLUGIN" : "reaction rule",
    "OWNER" : "rules",
    "TAGS" : [ "setup Fee" ],
    "REQUIRES" : [ "rules", "commerce_price", "commerce_cart" ],
    "ON" : { "commerce_cart_product_add" : [] },
    "IF" : [
      { "entity_is_of_bundle" : {
          "entity" : [ "commerce-product" ],
          "type" : "commerce_product",
          "bundle" : { "value" : { "moulding" : "moulding" } }
        }
      },
      { "data_is" : {
          "data" : [ "commerce-product:field-made-to-order" ],
          "value" : "Made To Order usually ships in 2-3 Weeks"
        }
      },
      { "data_is" : { "data" : [ "commerce-product:field-uom" ], "value" : "LF" } },
      { "commerce_price_compare_price" : {
          "first_price" : [ "commerce-line-item:commerce-total" ],
          "operator" : "\u003C",
          "second_price" : { "value" : { "amount" : 25000, "currency_code" : "USD" } }
        }
      }
    ],
    "DO" : [
      { "commerce_cart_product_add_by_sku" : {
          "USING" : {
            "user" : [ "site:current-user" ],
            "sku" : "0909990000005",
            "quantity" : "1",
            "combine" : 1
          },
          "PROVIDE" : { "product_add_line_item" : { "product_add_line_item" : "Added product line item" } }
        }
      }
    ]
  }
}

however I can't seem to figure out how to get it to remove the fee from the cart when they update their order to over $250 or they remove the moulding from the cart

I have tried following Randy Fays Removing Items From the Cart Using Rules

tutorial and adding a second component loop to check for the setup fee and remove it but it seems to not be able to find the setup fee under a product type of services and fees and the debugger isn't helping me at all because it says that the services and fees bundle comparison is false (even when it should be true) even though its the same as the one for moulding (except of course it's set to services and fees instead of moulding)

If anyone out there knows how I might change this to make it work please enlighten me

I posted this over on drupal.stackexchange.com yesterday hoping I was missing something simple

Asked by: ccg121
on December 19, 2013

1 Answer