Hi,
This may well be a bug with my implementation, but here is my scenario:
I have a hook_commerce_checkout_pane_info_alter() implementation:
/**
* Implements hook_commerce_checkout_pane_info_alter
*
*/
function site_registration_extras_commerce_checkout_pane_info_alter(&$checkout_panes) {
$checkout_panes['registration_information']['callbacks']['review'] = 'site_registration_extras_review_pane';
}
In the review pane callback I spit out some information about any registrations attached to the order, but it could be any scenario that accesses order data based on the entity_metadata_wrapper:
function site_registration_extras_review_pane($form, $form_state, $checkout_pane, $order) {
$msg = '';
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$l = 0;
foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
if (!in_array($line_item_wrapper->type->value(), commerce_product_line_item_types())) {
continue;
}
// do the display stuff here
What I'm finding is that the normal page load this is fine, but if a user changes the payment type and an AJAX reload is performed I'm getting a 'EntityMetadataWrapperException: Unable to get the data property type as the parent data structure is not set.'
I've narrowed it down to this line:
if (!in_array($line_item_wrapper->type->value(), commerce_product_line_item_types())) {
If I update the above to have an extra re-load of the order:
$msg = '';
// Reload the order
$order = commerce_order_load($order->order_id);
$order_wrapper = entity_metadata_wrapper('commerce_order', $order);
$l = 0;
foreach ($order_wrapper->commerce_line_items as $delta => $line_item_wrapper) {
if (!in_array($line_item_wrapper->type->value(), commerce_product_line_item_types())) {
continue;
}
This error goes away and the site is happy again.
Is there anything different when the AJAX re-load is called compared to when the review page is called normally that would produce this behaviour?
I have a workaround for now and it's in my custom module so it's not urgent for me, but in case this is an underlying bug or someone else bumps into it.
Cheers
Tom
Comments
Comment #2
torgospizzaThis sounds like #1804592: During AJAX form submission in checkout, the $order argument passed by the Form API is incorrect..
Comment #3
torgospizzaIn fact I'll probably mark this as a duplicate for now, but feel free to reopen if you feel otherwise.