Location: PHPKode > projects > Quick.Cart - free and simple to use shopping cart script > actions_client/p_orders.php
<?php
if( !defined( 'CUSTOMER_PAGE' ) )
  exit;

if( $config['basket_page'] == $iContent ){
  // basket
  if( isset( $_POST['aProducts'] ) ){
    // save basket
    $oOrder->saveBasket( $_POST );
    if( isset( $_POST['sSave'] ) ){
      setCookie( 'sCustomer'.LANGUAGE, md5( $_SESSION['iCustomer'.LANGUAGE] ), time( ) + 259200 );
    }
    if( isset( $_POST['sNext'] ) && isset( $config['order_page'] ) && isset( $oPage->aPages[$config['order_page']] ) ){
      header( 'Location: '.$_SERVER['PHP_SELF'].$oPage->aPages[$config['order_page']]['sLinkName'] );
      exit;
    }
  }
  if( isset( $iProductDelete ) && is_numeric( $iProductDelete ) ){
    // delete product from basket
    $oOrder->deleteFromBasket( $iProductDelete );
  }
  if( isset( $_POST['iProductAdd'] ) && isset( $_POST['iQuantity'] ) ){
    $iProductAdd = $_POST['iProductAdd'];
    $iQuantity = $_POST['iQuantity'];
  }
  if( isset( $iProductAdd ) && is_numeric( $iProductAdd ) && isset( $iQuantity ) && is_numeric( $iQuantity ) && $iQuantity > 0 && $iQuantity < 10000 && isset( $oProduct->aProducts[$iProductAdd] ) && is_numeric( $oProduct->aProducts[$iProductAdd]['mPrice'] ) ){
    // add product to basket
    $oOrder->addToBasket( $iProductAdd, $iQuantity );
    header( 'Location: '.$_SERVER['PHP_SELF'].$aData['sLinkName'] );
    exit;
  }
  // display basket
  $sBasketList = $oOrder->listProducts( 'orders_basket.tpl' );
  if( !isset( $sBasketList ) )
    $sBasketList = $oTpl->tbHtml( 'orders_basket.tpl', 'BASKET_EMPTY' );
}
else{
  $sBasketList = null;
}

if( $config['order_page'] == $iContent ){
  // order
  if( $oOrder->checkEmptyBasket( ) === false ){
    if( isset( $_POST['sOrderSend'] ) ){
      if( $oOrder->checkFields( $_POST ) === true ){
        // save and print order
        $iOrder = $oOrder->addOrder( $_POST );
        if( !empty( $config['orders_email'] ) ){
          $oOrder->sendEmailWithOrderDetails( 'orders_print.tpl', $iOrder, $config['send_customer_order_details'] );
        }

        $aOrder = $oOrder->throwOrder( $iOrder );
        $aOrder['sComment'] = preg_replace( '/\|n\|/', '<br />' , $aOrder['sComment'] );
        $sOrderProducts = $oOrder->listProducts( 'orders_print.tpl', $iOrder, 'ORDER_PRINT_' );
        $sOrder = $oTpl->tbHtml( 'orders_print.tpl', 'ORDER_PRINT' );
      }
      else{
        $sOrder = $oTpl->tbHtml( 'messages.tpl', 'REQUIRED_FIELDS' );
      }
    }
    else{
      // display order form
      $oTpl->unsetVariables( );
      $sRules = null;
      if( isset( $config['rules_page'] ) && isset( $oPage->aPages[$config['rules_page']] ) ){
        $aRules = $oPage->aPages[$config['rules_page']];
        $sRules = $oTpl->tbHtml( 'orders_form.tpl', 'RULES_ACCEPT' );
      }
      $sOrderProducts = $oOrder->listProducts( 'orders_form.tpl', null, 'ORDER_PRODUCTS_' );
      $sPaymentCarriers = $oOrder->listCarriersPayments( 'orders_form.tpl' );
      $oTpl->unsetVariables( );
      $sOrder = $oTpl->tbHtml( 'orders_form.tpl', 'ORDER_FORM' );
    }
  }
  else{
    $sOrder = $oTpl->tbHtml( 'orders_basket.tpl', 'BASKET_EMPTY' );
  }
}
else{
  $sOrderForm = null;
}
?>
Return current item: Quick.Cart - free and simple to use shopping cart script