Пример #1
0
 function import_excel()
 {
     if ($_FILES['fileExcel']['tmp_name']) {
         $this->_db =& JFactory::getDBO();
         $dom = DOMDocument::load($_FILES['fileExcel']['tmp_name']);
         $rows = $dom->getElementsByTagName('Row');
         $first_row = 0;
         foreach ($rows as $row) {
             if ($first_row > 0) {
                 $id = "";
                 $name = "";
                 $price = "";
                 $index = 1;
                 $cells = $row->getElementsByTagName('Cell');
                 foreach ($cells as $cell) {
                     $key = "";
                     if ($index == 1) {
                         $key = 'id';
                     }
                     if ($index == 2) {
                         $key = 'name';
                     }
                     if ($index == 3) {
                         $key = 'price';
                     }
                     ${$key} = $cell->nodeValue;
                     $index += 1;
                 }
                 $id = intval($id);
                 $price = doubleval($price);
                 if ($id && $price) {
                     $query = "update  #__pr_product set price = {$price} where id= {$id}";
                     $this->_db->setQuery($query);
                     $this->_db->query();
                 }
             }
             $first_row++;
         }
         die("Đã cap nhat  thành công  gia cua " . ($first_row - 1) . "san pham");
     } else {
         parent::display();
     }
 }
Пример #2
0
 function getDiscount($code)
 {
     $ec = new EcommerceController();
     $promo = $ec->get_promo($code);
     if ($promo) {
         if ($promo->is_percent == 1) {
             return $promo->discount / 100 * $this->getTotal();
         } else {
             return $promo->discount;
         }
     } else {
         return 0;
     }
 }
Пример #3
0
<?php

defined('_JEXEC') or die('Restricted access');
require_once JPATH_COMPONENT . DS . 'controller.php';
JTable::addIncludePath(JPATH_ADMINISTRATOR . DS . 'components' . DS . 'com_ecommerce' . DS . 'tables');
$controller = new EcommerceController();
$controller->execute(JRequest::getVar('task'));
$controller->redirect();
Пример #4
0
<?php

defined('_JEXEC') or die('Restricted access');
require_once 'components/com_ecommerce/controller.php';
$ecom_config = EcommerceController::getConfig();
require JModuleHelper::getLayoutPath('mod_cart');
Пример #5
0
function ecommerce_frontend($page)
{
    $ec = new EcommerceController();
    include 'classes/cart.class.php';
    ob_start();
    $page->_executeLayout();
    $output = ob_get_contents();
    ob_end_clean();
    $uri_arr = explode('/', $page->url);
    if (in_array('products', $uri_arr)) {
        $cart = new Cart('shopping_cart');
        // search
        if (in_array('search', $uri_arr)) {
            $keywords = !empty($_GET['keywords']) ? $_GET['keywords'] : '';
            $output = str_replace('<!-- ecommerce -->', $ec->products_search($keywords), $output);
        }
        // cart
        if (in_array('cart', $uri_arr)) {
            // add item to cart
            if (!empty($_POST['variant_id']) && !empty($_POST['quantity'])) {
                $quantity = $cart->getItemQuantity($_POST['variant_id']) + $_POST['quantity'];
                $cart->setItemQuantity($_POST['variant_id'], $quantity);
            }
            //update cart item quantity
            if (!empty($_POST['quantity'])) {
                if (is_array($_POST['quantity'])) {
                    foreach ($_POST['quantity'] as $variant_id => $quantity) {
                        $cart->setItemQuantity($variant_id, $quantity);
                    }
                }
            }
            // remove item from cart
            if (!empty($_POST['remove'])) {
                foreach ($_POST['remove'] as $variant_id) {
                    $cart->setItemQuantity($variant_id, 0);
                }
            }
            if (!empty($_POST['variant_id']) || !empty($_POST['quantity']) || !empty($_POST['remove'])) {
                $cart->save();
            }
            $output = str_replace('<!-- ecommerce -->', $cart->display(), $output);
        }
        // checkout
        if (in_array('checkout', $uri_arr)) {
            if ($cart->hasItems()) {
                $output = str_replace('<!-- ecommerce -->', $ec->checkout(), $output);
            } else {
                $output = str_replace('<!-- ecommerce -->', '<p>You have no items in your cart.</p>', $output);
            }
        }
        //product display
        if (count($uri_arr) == 1) {
            // products main page display
            $output = str_replace('<!-- ecommerce -->', $ec->products_all(), $output);
        } else {
            // display products by type
            if (in_array('types', $uri_arr)) {
                if ($page->slug == 'types') {
                    $output = str_replace('<!-- ecommerce -->', $ec->product_types_nav(), $output);
                } else {
                    $output = str_replace('<!-- ecommerce -->', $ec->products_by_type($page->slug), $output);
                }
            } else {
                if (in_array('vendors', $uri_arr)) {
                    $output = str_replace('<!-- ecommerce -->', $ec->products_by_vendor($page->slug), $output);
                } else {
                    $output = str_replace('<!-- ecommerce -->', $ec->product_show($page->slug), $output);
                }
            }
        }
        //add cart actions
        if ($cart->hasItems()) {
            $cart_actions = '<div id="cart-actions"><ul>';
            if (!in_array('cart', $uri_arr)) {
                $cart_actions .= '<li><a href="/products/cart">View Cart</a></li>';
            }
            if (!in_array('checkout', $uri_arr) && !in_array('cart', $uri_arr)) {
                $cart_actions .= '<li class="last"><a href="https://www.emedamerica.com/products/checkout">Checkout</a></li>';
            }
            $cart_actions .= '</ul></div>';
            $output = str_replace('<!-- ecommerce cart actions -->', $cart_actions, $output);
        }
    }
    // add ecommerce stylesheet to the frontend layout
    $output = str_replace('</head>', '<link rel="stylesheet" href="/public/ecommerce/ecommerce.css" type="text/css" /></head>', $output);
    //add ecommerce js file
    $output = str_replace('</head>', '<script type="text/javascript" charset="utf-8" src="/public/ecommerce/ecommerce.js"></script></head>', $output);
    // add flash to the frontend
    if ($ec->get_flash()) {
        $output = str_replace('<!-- ecommerce flash -->', $ec->get_flash(), $output);
    }
    // write frontend output
    echo $output;
    // clear the flash
    $_SESSION['ecommerce_flash'] = '';
    die;
}
Пример #6
0
 function display()
 {
     parent::display();
 }