1

I've created a rule with the intention of pulling an address from the users account and creating a shipping customer profile type instead of showing the user an address field to enter shipping (The site is designed for customers to sell to their customers so someone might be looking over their shoulder and we don't want them to have to type their address in multiple times a day (even if it's saved)) while the rule creates a shipping profile type just fine if I don't have the shipping information pane in the process I don't get rates however I can look at the backend and have a properly (as far as I can tell) filled in shipping profile

A copy of my rule so far:

{ "rules_shipping_address_test" : {
    "LABEL" : "shipping Address Test",
    "PLUGIN" : "reaction rule",
    "WEIGHT" : "-10",
    "OWNER" : "rules",
    "REQUIRES" : [ "rules", "commerce_shipping" ],
    "ON" : { "commerce_shipping_collect_rates" : [] },
    "DO" : [
      { "entity_create" : {
          "USING" : {
            "type" : "commerce_customer_profile",
            "param_type" : "shipping",
            "param_user" : [ "commerce-order:owner" ]
          },
          "PROVIDE" : { "entity_created" : { "shipping_info_unsaved" : "Customer Profile Shipping information Unsaved" } }
        }
      },
      { "data_set" : {
          "data" : [ "shipping-info-unsaved:commerce-customer-address" ],
          "value" : [ "site:current-user:field-primary-shipping-address" ]
        }
      },
      { "entity_save" : { "data" : [ "shipping-info-unsaved" ], "immediate" : "1" } }
    ]
  }
}

(it's not important now but in the future I'm planning on allowing the user to choose between 2 profiles on their account)

Update 1: After looking at a dsm of the order on a backend administration view that I was attempting to add shipping to I find that commerce_customer_shipping is an empty array which I assume is my problem that even though I'm creating and saving a profile it's not being set to the order?

1
  • Indent all code 4 spaces, not only first line. There is a button for that.
    – Mołot
    Dec 14, 2015 at 6:02

1 Answer 1

1

It doesn't appear that you're assigning the profile you created to the order. You need to set the order's shipping profile to the one you just created.

1
  • I just found this and fixed it with rules php (I already had it installed for something else) Dec 14, 2015 at 14:52

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.