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

$aUrls = throwSiteUrls( );

if( $config['basket_page'] == $iContent ){
  $sBasketList = null;
  // basket
  if( isset( $_POST['aProducts'] ) ){
    // save basket
    $oOrder->saveBasket( $_POST['aProducts'] );
    if( isset( $_POST['sRemember'] ) ){
      setCookie( 'sCustomer'.LANGUAGE, md5( $_SESSION['iCustomer'.LANGUAGE] ), time( ) + 259200 );
      $sBasketList .= $oTpl->tBlock( 'messages.tpl', 'DONE' );
    }
    if( isset( $_POST['sCheckout'] ) && isset( $config['order_page'] ) && isset( $oPage->aPages[$config['order_page']] ) ){
      header( 'Location: '.dirname( $aUrls['sUrl'] ).'/'.( defined( 'MOBILE' ) ? 'mobile.php' : null ).$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 ) ){
    $oProduct = Products::getInstance( );

    if( isset( $oProduct->aProducts[$iProductAdd] ) && is_numeric( $oProduct->aProducts[$iProductAdd]['mPrice'] ) ){
      // add product to basket
      $oOrder->saveBasket( Array( $iProductAdd => $iQuantity ), true );
      header( 'Location: '.dirname( $aUrls['sUrl'] ).'/'.( defined( 'MOBILE' ) ? 'mobile.php' : null ).$aData['sLinkName'] );
      exit;
    }
  }
  // display basket
  
  $sBasketList .= $oOrder->listProducts( 'orders_step-1.tpl' );
  if( empty( $sBasketList ) )
    $sBasketList = $oTpl->tBlock( 'messages.tpl', 'BASKET_EMPTY' );
}

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_step-3.tpl', $iOrder, $config['send_customer_order_details'] );
        }

        $aOrder = $oOrder->throwOrder( $iOrder );
        $aOrder['sComment'] = isset( $aOrder['sComment'] ) ? preg_replace( '/\|n\|/', '<br />' , $aOrder['sComment'] ) : null;
        $sOrderProducts = $oOrder->listProducts( 'orders_step-3.tpl', $iOrder, 'PRINT_' );
        $sOrder = $oTpl->tBlock( 'orders_step-3.tpl', 'ORDER_PRINT' );
      }
      else{
        $sOrder = $oTpl->tBlock( 'messages.tpl', 'REQUIRED_FIELDS' );
      }
    }
    else{
      // display order form
      $oTpl->unsetVariables( );
      if( isset( $config['rules_page'] ) && isset( $oPage->aPages[$config['rules_page']] ) ){
        $aRules = $oPage->aPages[$config['rules_page']];
        $oTpl->setIfGlobal( 'RULES-ACCEPT' );
      }

      $sOrderProducts = $oOrder->listProducts( 'orders_step-2.tpl', null );
      $sShippingPaymentsSelect = $oOrder->throwShippingPaymentsSelect( );
      
      $oTpl->unsetVariables( );
      $sOrder = $oTpl->tBlock( 'orders_step-2.tpl', 'ORDER_FORM' );
    }
  }
  else{
    $sOrder = $oTpl->tBlock( 'messages.tpl', 'BASKET_EMPTY' );
  }
}
?>
Return current item: Quick.Cart - free and simple to use shopping cart script