0

I have a commerce store that sells both physical and virtual products. To streamline the checkout process, I'm using hook_commerce_checkout_pane_info_alter to check orders and removing shipping altogether if the order doesn't contain any physical products. The code that removes the shipping pane is:

$checkout_pane['customer_profile_shipping']['enabled'] = FALSE;

This works fine. However, I am also using the rule "Create a new account for an anonymous order" to allow anonymous users to purchase. When orders that don't contain physical products (so have no shipping information, the rule throws an error when trying to set the uid for shipping:

Unable to modify data "commerce-order:commerce-customer-shipping:uid": Unable to set the data property uid as the parent data structure is not set.

The order still goes to checkout complete, but the errors are logged in the watchdog table.

How can I gracefully resolve this error?

  • Can you split the rule - have it conditionally set data, depending on whether or not the shipping data exists? – Geoff Jun 13 '14 at 17:50
  • OK, that's a good idea. Looking at the rule again, what I could do is create a custom action that sets commerce-customer-shipping:uid conditionally (only if it exists). Right now, the action is just the generic "Set a data value" action, and I don't think there's any way for me to make it conditional, since it's running inside a rule with several other actions and other independent conditions. – Dave Bruns Jun 13 '14 at 21:25

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.