It seems I am able to delete the default Customer Billing Profile field for the Order Entity.
Without it the commerce (checkout) is broken.

Error
The website encountered an unexpected error. Please try again later.

Error message
EntityMetadataWrapperException: Unknown data property commerce_customer_billing. in EntityStructureWrapper->getPropertyInfo() (line 339 of drupal_path/sites/all/modules/contrib/entity/includes/entity.wrapper.inc).

Shouldn't be locked somehow?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

vasike’s picture

Component: Checkout » Order
Status: Active » Needs review
FileSize
1.17 KB

here is a patch

i don't know if this should be the solution, or it's ok to have this field unlocked and to fix the bug within checkout module.

rszrama’s picture

Version: 7.x-1.3 » 7.x-1.x-dev
Priority: Critical » Normal
Status: Needs review » Needs work

We actually don't require this on purpose, allowing sites to remove the default billing profile association if they so choose. In that case, I'm guessing checkout was broken for you because you were still showing the billing information checkout pane. If you disable that, it should not provide errors, or if you were to add a different customer profile reference field to your order bundle, then you could update the checkout pane settings to use that field instead.

Perhaps the real fix here to preserve this behavior would be to disable the billing information checkout pane if the customer profile reference field it's been configured to use is removed from the order bundle.

vasike’s picture

i see,
so where do you think this fix should take place, in which module? checkout or customer?

vasike’s picture

there's something else:
I delete the Customer Billing field.
I save the 'Billing information' checkout pane with NO Related customer profile reference field
I go the checkout page
Surprise i have the Billing information inputs right in the checkout form.
and The data is saved the Address (commerce_customer_address) field tables.

How it should be the right way?
I' m thinking to have a validation for this Customer checkout pane and disable it if there's no Related customer profile reference field selected.

rszrama’s picture

Sounds like we should also then make sure that pane is not enabled without a valid reference field selected. : D

We can patch both of these issues in the Customer module.

vasike’s picture

Title: Customer Billing Profile Order field unlocked » Disable the Customer Profiles Panes if there are NO Related customer profile reference field
Status: Needs work » Needs review
FileSize
4.77 KB

here is patch for this (rough stuff).

i found 2 more cases:

  1. The Checkout panes page (Panes ordering)
  2. The customer profile reference fields are deleted BEFORE the Checkout module install.
cvangysel’s picture

Assigned: Unassigned » cvangysel

I'll have a look at this.

cvangysel’s picture

I cleaned up the code a bit and removed some of the hacky stuff. The only thing I don't necessarily like about my patch is that the error message when trying to move a customer profile pane that hasn't got a customer profile referenced is a little general.

But then again, when you're deleting entity fields I guess you should know what it is you're doing.

joshmiller’s picture

Status: Needs review » Reviewed & tested by the community

Patch looks clean; Confirmed bug (wow!); Applied patch; Bug immediately fixed; Re-installed site and bug is non-existant.

All is well and bug is gone. Love the hook_field_delete_field() ... not sure what it does or why it's necessary.

rszrama’s picture

Assigned: cvangysel » Unassigned
Status: Reviewed & tested by the community » Fixed

Alrighty, in she goes. As for that function, Josh, it basically updates any checkout panes that may have been based on the customer profile reference field to disable them. And agreed w/ Christophe - if you're deleting these fields, you should know what you're doing. No need to go overboard on the error messages. : )

Thanks to vasike for starting this out and the others for driving it home.

Status: Fixed » Closed (fixed)

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