Projet

Général

Profil

Paste
Télécharger (1,71 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / commerce / modules / cart / includes / commerce_cart.admin.inc @ b858700c

1
<?php
2

    
3
/**
4
 * @file
5
 * Administrative forms and page callbacks for the Cart module.
6
 */
7

    
8

    
9
/**
10
 * Form callback: confirmation form for manually refreshing an order.
11
 *
12
 * @param $order
13
 *   The order object to apply the card refresh to.
14
 *
15
 * @return
16
 *   The form array to confirm the refresh.
17
 *
18
 * @see confirm_form()
19
 */
20
function commerce_cart_order_refresh_form($form, &$form_state, $order) {
21
  $form['order_id'] = array(
22
    '#type' => 'value',
23
    '#value' => $order->order_id,
24
  );
25

    
26
  // Build a description of what the user may expect to occur on submission.
27
  $items = array(
28
    t('All product prices will be reset and recalculated using the product pricing rules defined on this site.'),
29
    t('Non-product line items may or may not be updated depending on the type.'),
30
    t('Custom prices entered on the edit form will be lost.'),
31
  );
32

    
33
  $form = confirm_form($form,
34
    t('Are you sure you want to apply pricing rules to order @number?', array('@number' => $order->order_number)),
35
    'admin/commerce/orders/' . $order->order_id . '/edit',
36
    '<p>' . theme('item_list', array('items' => $items)) . '</p>',
37
    t('Apply pricing rules'),
38
    t('Cancel')
39
  );
40

    
41
  return $form;
42
}
43

    
44
/**
45
 * Form submit callback for commerce_cart_order_refresh_form().
46
 */
47
function commerce_cart_order_refresh_form_submit($form, &$form_state) {
48
  if ($order = commerce_order_load($form_state['values']['order_id'])) {
49
    commerce_cart_order_refresh($order);
50
    drupal_set_message(t('Pricing rules have been applied and the order updated.'));
51
    $form_state['redirect'] = 'admin/commerce/orders/' . $order->order_id . '/edit';
52
  }
53
  else {
54
    drupal_set_message(t('Order not found.'), 'error');
55
    $form_state['redirect'] = 'admin/commerce/orders';
56
  }
57
}