[ Index ]
 

Code source de Zen Cart E-Commerce Shopping Cart 1.3.7.1

Accédez au Source d'autres logiciels libres

Classes | Fonctions | Variables | Constantes | Tables

title

Body

[fermer]

/includes/modules/pages/checkout_confirmation/ -> header_php.php (source)

   1  <?php
   2  /**

   3   * checkout_confirmation header_php.php

   4   *

   5   * @package page

   6   * @copyright Copyright 2003-2006 Zen Cart Development Team

   7   * @copyright Portions Copyright 2003 osCommerce

   8   * @license http://www.zen-cart.com/license/2_0.txt GNU Public License V2.0

   9   * @version $Id: header_php.php 5324 2006-12-21 17:41:25Z drbyte $

  10   */
  11  
  12  // This should be first line of the script:

  13  $zco_notifier->notify('NOTIFY_HEADER_START_CHECKOUT_CONFIRMATION');
  14  
  15  // if there is nothing in the customers cart, redirect them to the shopping cart page

  16  if ($_SESSION['cart']->count_contents() <= 0) {
  17      zen_redirect(zen_href_link(FILENAME_TIME_OUT));
  18  }
  19  
  20  // if the customer is not logged on, redirect them to the login page

  21    if (!$_SESSION['customer_id']) {
  22      $_SESSION['navigation']->set_snapshot(array('mode' => 'SSL', 'page' => FILENAME_CHECKOUT_PAYMENT));
  23      zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  24    } else {
  25      // validate customer

  26      if (zen_get_customer_validate_session($_SESSION['customer_id']) == false) {
  27        $_SESSION['navigation']->set_snapshot();
  28        zen_redirect(zen_href_link(FILENAME_LOGIN, '', 'SSL'));
  29      }
  30    }
  31  
  32  // avoid hack attempts during the checkout procedure by checking the internal cartID

  33  if (isset($_SESSION['cart']->cartID) && $_SESSION['cartID']) {
  34    if ($_SESSION['cart']->cartID != $_SESSION['cartID']) {
  35      zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  36    }
  37  }
  38  
  39  // if no shipping method has been selected, redirect the customer to the shipping method selection page

  40  if (!$_SESSION['shipping']) {
  41    zen_redirect(zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
  42  }
  43  
  44  if (isset($_POST['payment'])) $_SESSION['payment'] = $_POST['payment'];
  45  $_SESSION['comments'] = zen_db_prepare_input($_POST['comments']);
  46  
  47  //'checkout_payment_discounts'

  48  //zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));

  49  
  50  
  51  if (DISPLAY_CONDITIONS_ON_CHECKOUT == 'true') {
  52    if (!isset($_POST['conditions']) || ($_POST['conditions'] != '1')) {
  53      $messageStack->add_session('checkout_payment', ERROR_CONDITIONS_NOT_ACCEPTED, 'error');
  54    }
  55  }
  56  //echo $messageStack->size('checkout_payment');

  57  
  58  require(DIR_WS_CLASSES . 'order.php');
  59  $order = new order;
  60  
  61  require(DIR_WS_CLASSES . 'order_total.php');
  62  $order_total_modules = new order_total;
  63  $order_total_modules->collect_posts();
  64  $order_total_modules->pre_confirmation_check();
  65  
  66  // load the selected payment module

  67  require(DIR_WS_CLASSES . 'payment.php');
  68  
  69  if ($credit_covers) {
  70    unset($_SESSION['payment']);
  71    $_SESSION['payment'] = '';
  72  }
  73  
  74  
  75  $payment_modules = new payment($_SESSION['payment']);
  76  $payment_modules->update_status();
  77  if (($_SESSION['payment'] == '' && !$credit_covers) || (is_array($payment_modules->modules)) && (sizeof($payment_modules->modules) > 1) && (!is_object($$_SESSION['payment'])) && (!$credit_covers) ) {
  78    $messageStack->add_session('checkout_payment', ERROR_NO_PAYMENT_MODULE_SELECTED, 'error');
  79  }
  80  
  81  if (is_array($payment_modules->modules)) {
  82    $payment_modules->pre_confirmation_check();
  83  }
  84  
  85  if ($messageStack->size('checkout_payment') > 0) {
  86    zen_redirect(zen_href_link(FILENAME_CHECKOUT_PAYMENT, '', 'SSL'));
  87  }
  88  //echo $messageStack->size('checkout_payment');

  89  //die('here');

  90  
  91  // load the selected shipping module

  92  require(DIR_WS_CLASSES . 'shipping.php');
  93  $shipping_modules = new shipping($_SESSION['shipping']);
  94  
  95  // Stock Check

  96  $flagAnyOutOfStock = false;
  97  $stock_check = array();
  98  if (STOCK_CHECK == 'true') {
  99    for ($i=0, $n=sizeof($order->products); $i<$n; $i++) {
 100      if ($stock_check[$i] = zen_check_stock($order->products[$i]['id'], $order->products[$i]['qty'])) {
 101        $flagAnyOutOfStock = true;
 102      }
 103    }
 104    // Out of Stock

 105    if ( (STOCK_ALLOW_CHECKOUT != 'true') && ($flagAnyOutOfStock == true) ) {
 106      zen_redirect(zen_href_link(FILENAME_SHOPPING_CART));
 107    }
 108  }
 109  
 110  // update customers_referral with $_SESSION['gv_id']

 111  if ($_SESSION['cc_id']) {
 112    $discount_coupon_query = "SELECT coupon_code
 113                              FROM " . TABLE_COUPONS . "
 114                              WHERE coupon_id = :couponID";
 115  
 116    $discount_coupon_query = $db->bindVars($discount_coupon_query, ':couponID', $_SESSION['cc_id'], 'integer');
 117    $discount_coupon = $db->Execute($discount_coupon_query);
 118  
 119    $customers_referral_query = "SELECT customers_referral
 120                                 FROM " . TABLE_CUSTOMERS . "
 121                                 WHERE customers_id = :customersID";
 122  
 123    $customers_referral_query = $db->bindVars($customers_referral_query, ':customersID', $_SESSION['customer_id'], 'integer');
 124    $customers_referral = $db->Execute($customers_referral_query);
 125  
 126    // only use discount coupon if set by coupon

 127    if ($customers_referral->fields['customers_referral'] == '' and CUSTOMERS_REFERRAL_STATUS == 1) {
 128      $sql = "UPDATE " . TABLE_CUSTOMERS . "
 129              SET customers_referral = :customersReferral
 130              WHERE customers_id = :customersID";
 131  
 132      $sql = $db->bindVars($sql, ':customersID', $_SESSION['customer_id'], 'integer');
 133      $sql = $db->bindVars($sql, ':customersReferral', $discount_coupon->fields['coupon_code'], 'string');
 134      $db->Execute($sql);
 135    } else {
 136      // do not update referral was added before

 137    }
 138  }
 139  
 140  if (isset($$_SESSION['payment']->form_action_url)) {
 141    $form_action_url = $$_SESSION['payment']->form_action_url;
 142  } else {
 143    $form_action_url = zen_href_link(FILENAME_CHECKOUT_PROCESS, '', 'SSL');
 144  }
 145  
 146  // if shipping-edit button should be overridden, do so

 147  $editShippingButtonLink = zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL');    
 148  if (method_exists($$_SESSION['payment'], 'alterShippingEditButton')) {
 149    $theLink = $$_SESSION['payment']->alterShippingEditButton();
 150    if ($theLink) $editShippingButtonLink = $theLink;
 151  }
 152  // deal with billing address edit button

 153  $flagDisablePaymentAddressChange = false;
 154  if (isset($$_SESSION['payment']->flagDisablePaymentAddressChange)) {
 155    $flagDisablePaymentAddressChange = $$_SESSION['payment']->flagDisablePaymentAddressChange;
 156  }
 157  
 158  
 159  require(DIR_WS_MODULES . zen_get_module_directory('require_languages.php'));
 160  $breadcrumb->add(NAVBAR_TITLE_1, zen_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'));
 161  $breadcrumb->add(NAVBAR_TITLE_2);
 162  
 163  // This should be last line of the script:

 164  $zco_notifier->notify('NOTIFY_HEADER_END_CHECKOUT_CONFIRMATION');
 165  ?>


Généré le : Mon Nov 26 16:45:43 2007 par Balluche grâce à PHPXref 0.7
  Clicky Web Analytics