Hi,
When adding a new order via admin/commerce/orders/add, clicking on "Add an order" throw an EntityMetadataWrapperException.
Reporting to watchdog, the issue is related to commerce_registration_form_commerce_order_ui_order_form_alter, where $data['line_item_id'] is not defined.
I did this to make it working:
foreach ($form_state['values']['commerce_line_items'] as $lang => $items) {
foreach ($items as $index => $data) {
$line_item = commerce_line_item_load((int) $data['line_item_id']);
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
if ($line_item_wrapper->type->value() != 'product') {
continue;
}
$product_id = $line_item_wrapper->commerce_product->product_id->value();
if (in_array($product_id, array_keys($products))) {
$products[$product_id]++;
}
else {
$products[$product_id] = 1;
}
}
}
replaced by:
foreach ($form_state['values']['commerce_line_items'] as $lang => $items) {
foreach ($items as $index => $data) {
if (isset($data['line_item_id'])) {
$line_item = commerce_line_item_load((int) $data['line_item_id']);
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
if ($line_item_wrapper->type->value() != 'product') {
continue;
}
$product_id = $line_item_wrapper->commerce_product->product_id->value();
if (in_array($product_id, array_keys($products))) {
$products[$product_id]++;
}
else {
$products[$product_id] = 1;
}
}
}
}
Comments
Comment #1
sk33lz commentedThis issue is causing ajax to fail when editing an order with custom line item types in an inline entity form. The above code fixes the ajax error.
I have created a patch against the 7.x-2.x-dev release. See attached.
Comment #2
blacklabel_tom commentedHi,
I'm closing down the 3.x branch, with D8 around the corner I'll concentrate on getting the 2.x branch up to scratch and the re-write in D8 if necessary.
Cheers
Tom
Comment #3
dmsmidt@sk33lz, thank you anyways for the patch. This is was buggin me as well.
A pity this simple patch didn't make it in, D8 still isn't mainstream for all new projects.