Projet

Général

Profil

Révision b858700c

Ajouté par Assos Assos il y a environ 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/commerce/modules/checkout/commerce_checkout.module
81 81
    'file' => 'includes/commerce_checkout.admin.inc',
82 82
  );
83 83

  
84
  // If the Order UI module is installed, add a local action to it that lets an
85
  // administrator invoke the checkout completion event on the order. Modules
86
  // that define their own order edit menu item are also responsible for
87
  // defining their own local action menu items if needed.
88
  if (module_exists('commerce_order_ui')) {
89
    $items['admin/commerce/orders/%commerce_order/edit/checkout'] = array(
90
      'title' => 'Simulate checkout completion',
91
      'description' => 'Directly invokes the checkout completion rules on the order.',
92
      'page callback' => 'drupal_get_form',
93
      'page arguments' => array('commerce_checkout_complete_form', 3),
94
      'access callback' => 'commerce_checkout_complete_form_access',
95
      'access arguments' => array(3),
96
      'type' => MENU_LOCAL_ACTION,
97
      'file' => 'includes/commerce_checkout.admin.inc',
98
    );
99
  }
100

  
84 101
  return $items;
85 102
}
86 103

  
104
/**
105
 * Access callback: determines access to the "Simulate checkout completion"
106
 * local action.
107
 */
108
function commerce_checkout_complete_form_access($order) {
109
  // Returns TRUE if the link is enabled via the order settings form and the
110
  // user has access to update the order.
111
  return variable_get('commerce_order_simulate_checkout_link', TRUE) && commerce_order_access('update', 3);
112
}
113

  
87 114
/**
88 115
 * Implements hook_hook_info().
89 116
 */
......
257 284
  }
258 285
}
259 286

  
287
/**
288
 * Implements hook_form_FORM_ID_alter().
289
 *
290
 * Adds a checkbox to the order settings form to enable the local action on
291
 * order edit forms to simulate checkout completion.
292
 */
293
function commerce_checkout_form_commerce_order_settings_form_alter(&$form, &$form_state) {
294
  $form['commerce_order_simulate_checkout_link'] = array(
295
    '#type' => 'checkbox',
296
    '#title' => t('Enable the local action link on order edit forms to simulate checkout completion.'),
297
    '#default_value' => variable_get('commerce_order_simulate_checkout_link', TRUE),
298
    '#weight' => 20,
299
  );
300
}
301

  
260 302
/**
261 303
 * Implements hook_form_FORM_ID_alter().
262 304
 *
......
568 610
  return $checkout_panes;
569 611
}
570 612

  
613
/**
614
 * Resets the cached list of checkout panes.
615
 */
616
function commerce_checkout_panes_reset() {
617
  $checkout_panes = &drupal_static('commerce_checkout_panes');
618
  $checkout_panes = NULL;
619
}
620

  
571 621
/**
572 622
 * Saves a checkout pane's configuration to the database.
573 623
 *
......
848 898
  return 'checkout/' . $order->order_id . $page_id;
849 899
}
850 900

  
901
/**
902
 * Determines whether or not the given order can proceed to checkout.
903
 *
904
 * This function operates as a confirmation rather than a falsification, meaning
905
 * that any module implementing hook_commerce_checkout_order_can_checkout() can
906
 * confirm the order may proceed to checkout.
907
 *
908
 * The default core implementation is in commerce_product_reference.module and
909
 * allows any order containing a product line item to proceed to checkout.
910
 *
911
 * More complex logic can be implemented via hook_commerce_checkout_router().
912
 *
913
 * @param $order
914
 *   The order being confirmed for checkout.
915
 *
916
 * @return
917
 *   Boolean value indicating whether or not the order can proceed to checkout.
918
 *
919
 * @see commerce_product_reference_commerce_checkout_order_can_checkout()
920
 */
921
function commerce_checkout_order_can_checkout($order) {
922
  $proceed = FALSE;
923

  
924
  // Manually invoke hook functions to use the bitwise operator that will update
925
  // the return value to TRUE if any implementation returns TRUE and ignore any
926
  // FALSE return values if it is already set to TRUE.
927
  foreach (module_implements('commerce_checkout_order_can_checkout') as $module) {
928
    $function = $module . '_commerce_checkout_order_can_checkout';
929
    $proceed |= $function($order);
930
  }
931

  
932
  return $proceed;
933
}
934

  
851 935
/**
852 936
 * Completes the checkout process for the given order.
853 937
 */

Formats disponibles : Unified diff