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?