- Issue created by @seanenroute
What version of Webform Rules module are you running? I was getting the same issue when using Webform Rules 7.x-1.7.
Downgrading Webform Rules module back to 7.x-1.6 fixed the issue for me.
Here is a patch I applied that seems to work with Webform Rules 7.x-1.7:
In commerce_webform_get_products_from_webform_submission() in commerce_webform.module modify this function from this:
function commerce_webform_get_products_from_webform_submission($submission) { $product_ids = array(); $products = array(); $data = array(); $components = $submission['components']; foreach ($components as $component) { if ($component['component']['type'] == 'productfield') { foreach ($component['value'] as &$value) { $value = json_decode($value); if (!empty($value->product_id) && $value->quantity > 0) { $product_ids[] = $value->product_id; if (empty($data[$value->product_id])) { $data[$value->product_id] = $value; $data[$value->product_id]->required = $component['component']['required']; $data[$value->product_id]->choose_quantity = $component['component']['extra']['choose_quantity']; } else { // Now we need to change the quantity. $data[$value->product_id]->quantity = $data[$value->product_id]->quantity + $value->quantity; } } } } } $products = commerce_product_load_multiple($product_ids); foreach ($products as $product) { $data[$product->product_id]->product = $product; } return $data; }
Change it to this:
function commerce_webform_get_products_from_webform_submission($submission) { $product_ids = array(); $products = array(); $data = array(); $webform_node = reset($submission); $webform = node_load($webform_node->nid); $components = $webform->webform['components']; foreach ($webform_node->data as $cid => $val) { $c_key = $components[$cid]['form_key']; $webform_node->components[$c_key] = array( 'nid' => $components[$cid]['nid'], 'cid' => $cid, 'pid' => $components[$cid]['pid'], 'form_key' => $c_key, 'name' => $components[$cid]['name'], 'type' => $components[$cid]['type'], 'value' => $val, 'extra' => $components[$cid]['extra'], 'required' => $components[$cid]['required'], 'weight' => $components[$cid]['weight'], 'page_num' => $components[$cid]['page_num'], ); } foreach ($webform_node->components as $component) { if ($component['type'] == 'productfield') { foreach ($component['value'] as &$value) { $value = json_decode($value); if (!empty($value->product_id) && $value->quantity > 0) { $product_ids[] = $value->product_id; if (empty($data[$value->product_id])) { $data[$value->product_id] = $value; $data[$value->product_id]->required = $component['required']; $data[$value->product_id]->choose_quantity = $component['extra']['choose_quantity']; } else { // Now we need to change the quantity. $data[$value->product_id]->quantity = $data[$value->product_id]->quantity + $value->quantity; } } } } } $products = commerce_product_load_multiple($product_ids); foreach ($products as $product) { $data[$product->product_id]->product = $product; } return $data; }