From 5cead591d4e824557ffe26b3baa284eec4727d6a Mon Sep 17 00:00:00 2001 From: Matt Breden Date: Mon, 6 Nov 2017 11:01:52 -0800 Subject: [PATCH] Issue #2921376 by mbreden: Move stock-adding logic outside of an if-block checking if the customer exists in the form state (in commerce_pos_transaction_pay_submit()) Adding stock shouldn't depend on the customer being present in the form state values --- includes/commerce_pos.transaction.inc | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/includes/commerce_pos.transaction.inc b/includes/commerce_pos.transaction.inc index 3f5b940..72e22ac 100644 --- a/includes/commerce_pos.transaction.inc +++ b/includes/commerce_pos.transaction.inc @@ -715,14 +715,15 @@ function commerce_pos_transaction_pay_submit($form, &$form_state) { $form_state['transaction']->doAction('saveOrder'); } } - if (module_exists('commerce_pos_stock')) { - $order = commerce_order_load($form_state['transaction']->orderId); - $order_wrapper = entity_metadata_wrapper('commerce_order', $order); - foreach ($order_wrapper->commerce_line_items->value() as $line_item) { - if (!empty($form_state['input']['return_line_items'][$line_item->line_item_id]['commerce_pos_stock_add_to_stock'])) { - $line_item->data['commerce_pos_stock_add_to_stock'] = $form_state['input']['return_line_items'][$line_item->line_item_id]['commerce_pos_stock_add_to_stock']; - commerce_line_item_save($line_item); - } + } + + if (module_exists('commerce_pos_stock')) { + $order = commerce_order_load($form_state['transaction']->orderId); + $order_wrapper = entity_metadata_wrapper('commerce_order', $order); + foreach ($order_wrapper->commerce_line_items->value() as $line_item) { + if (!empty($form_state['input']['return_line_items'][$line_item->line_item_id]['commerce_pos_stock_add_to_stock'])) { + $line_item->data['commerce_pos_stock_add_to_stock'] = $form_state['input']['return_line_items'][$line_item->line_item_id]['commerce_pos_stock_add_to_stock']; + commerce_line_item_save($line_item); } } }