You are here

function commerce_discount_form_submit in Commerce Discount 7

Form API submit callback for the type form.

File

includes/commerce_discount.admin.inc, line 387
Commerce discount editing UI.

Code

function commerce_discount_form_submit(&$form, &$form_state) {
  $commerce_discount = entity_ui_form_submit_build_entity($form, $form_state);
  $commerce_discount
    ->save();

  // Set the redirect based on the type of the discount.
  if ($commerce_discount->type == 'order_discount') {
    $form_state['redirect'] = array(
      'admin/commerce/discounts',
      array(
        'query' => array(
          'type' => 'order_discount',
        ),
      ),
    );
  }
  else {
    $form_state['redirect'] = 'admin/commerce/discounts';
  }
}