Example #1
0
<?php

// no direct access
defined('SHOP_PARENT_FILE') or die('Restricted access');
$title .= 'Shopping Cart';
if ($this->ushop->global['offline'] || $this->ushop->global['catelogue_mode']) {
    $this->addContent('<h3>Shopping is unavialible</h3><p><a href="/ushop/view/shopfront">Click here to continue</a></p>');
} else {
    $item = $this->registry->params['id'];
    $cart = $this->ushop->retrieveCart();
    $this->content .= '<div id="products">';
    $this->content .= UShop_Utility::returnLink();
    switch ($this->registry->params['action']) {
        case 'add':
            $cart->addItem($item);
            break;
        case 'remove':
            $cart->removeItem($item);
            break;
        case 'update':
            if (isset($_POST['items'])) {
                foreach ($_POST['items'] as $key => $value) {
                    $cart->updateCart($key, $value);
                }
            }
            break;
        case 'empty':
            $cart->cart = null;
            break;
    }
    if (count($cart->cart['items']) > 0) {
Example #2
0
 public function displayCartInvoice($user)
 {
     $html = file_get_contents('ushop/html/invoice.html', true);
     $cart = $this->retrieveCart();
     $user_info = $this->getUserInfo($user);
     $params = array('CART' => $cart->displayCart(), 'USER_INFO' => $user_info['info'], 'USER_CDA' => $user_info['cda'], 'USER_EMAIL' => $user_info['email'], 'MERCHANT_DETAILS' => $this->getMerchantInfo());
     $html = Uthando::templateParser($html, $params, '{', '}');
     $html = preg_replace("/<th>(.*?)<\\/th>/s", "", $html);
     $remove = array('delete_item', 'item_quantity_input');
     if (!$this->invoice['display_top']) {
         $remove[] = 'top';
     }
     if (!$this->invoice['display_bottom']) {
         $remove[] = "bottom";
     }
     foreach ($remove as $value) {
         $html = UShop_Utility::removeSection($html, $value);
     }
     return $html;
 }
Example #3
0
 public function displayCart()
 {
     global $uthando;
     $cb = file_get_contents('ushop/html/cart_body.html', true);
     $ci = file_get_contents('ushop/html/cart_items.html', true);
     if (!$uthando->ushop->checkout['vat_state']) {
         $ci = UShop_Utility::removeSection($ci, 'vat');
     }
     if (!$uthando->ushop->checkout['vat_state']) {
         $cb = UShop_Utility::removeSection($cb, 'vat');
     }
     $params = array('COLSPAN' => $uthando->ushop->checkout['vat_state'] == 1 ? 3 : 2, 'CART_ITEMS' => null);
     $items = $this->calculateCartItems();
     if (is_array($items)) {
         foreach ($items as $item) {
             $tr = Uthando::templateParser($ci, $item, '{', '}');
             $params['CART_ITEMS'] .= $tr;
         }
         if (isset($_SESSION['CountryCode'])) {
             $this->calculatePostage();
         } else {
             $this->cart['postCost'] = 0;
             $this->cart['postTax'] = 0;
             $cb = UShop_Utility::removeSection($cb, 'postage');
         }
         $params = array_merge($params, $this->getCartTotals());
         $html = Uthando::templateParser($cb, $params, '{', '}');
     } else {
         $html = $items;
     }
     return $html;
 }