You are here

function uc_order_edit_products_remove in Ubercart 7.3

Form submit callback: remove a product from an order.

1 string reference to 'uc_order_edit_products_remove'
uc_order_edit_products_form in uc_order/uc_order.order_pane.inc
Form to allow ordered products' data to be changed.

File

uc_order/uc_order.order_pane.inc, line 586
This file contains the callbacks for the default order panes supplied with Ubercart and their corresponding helper functions.

Code

function uc_order_edit_products_remove($form, &$form_state) {
  $form_state['refresh_products'] = TRUE;
  $order_product_id = intval($form_state['triggering_element']['#return_value']);
  if (module_exists('uc_stock')) {

    // Replace stock immediately.
    $product = uc_order_product_load($order_product_id);
    uc_stock_adjust($product->model, $product->qty);
  }
  uc_order_product_delete($order_product_id);
  $order = $form_state['build_info']['args'][0];
  $matches = array();
  preg_match('/products\\[(\\d+)\\]/', $form_state['triggering_element']['#name'], $matches);
  $key = $matches[1];
  unset($order->products[$key]);
  $order->products = array_values($order->products);
}