function updateCart() { $Cart = new Shopping_Cart('shopping_cart'); if (!empty($_GET['id']) && !empty($_GET['quantity'])) { $quantity = $Cart->getItemQuantity($_GET['id']) + $_GET['quantity']; $Cart->setItemQuantity($_GET['id'], $quantity); } if (!empty($_GET['quantity'])) { foreach ($_GET['quantity'] as $id => $quantity) { $Cart->setItemQuantity($id, $quantity); } } if (!empty($_GET['remove'])) { foreach ($_GET['remove'] as $order_code) { $Cart->setItemQuantity($order_code, 0); } } $Cart->save(); }
<?php /** * @version 1.0 - Joomla 1.5.x * @package Component Com Products * @copyright Wampvn Group * @license GNU/GPL * @website http://wampvn.com * @description tpl raw cart. */ defined('_JEXEC') or die('Restricted access'); session_start(); $Cart = new Shopping_Cart('shopping_cart'); echo "--------------------"; if ($Cart->hasItems()) { ?> <ul class="cart_list_item"> <?php $total_price = 0; $total_price_vn = 0; foreach ($Cart->getItems() as $id => $cart) { if ($cart['currency'] == 'USD') { $total_price += $cart['count'] * $cart['price']; } else { $total_price_vn += $cart['count'] * $cart['price']; } echo '<li><p><span class="count" >' . $cart['count'] . '</span> x <span>' . $cart['name'] . '</span></p>'; echo '<p class="prices">' . number_format($cart['count'] * $cart['price']) . ' ' . $cart['currency'] . '</p>'; echo '</li>'; }
<?php /** * @version 1.0 - Joomla 1.5.x * @package Component Com Products * @copyright Wampvn Group * @license GNU/GPL * @website http://wampvn.com * @description tpl cart. */ defined('_JEXEC') or die('Restricted access'); $Cart = new Shopping_Cart('shopping_cart'); $msie = '/msie\\s(5\\.[5-9]|[7]\\.[0-9]*).*(win)/i'; $isIE7 = preg_match($msie, $_SERVER['HTTP_USER_AGENT']); ?> <h1 class="title_page_sub head_com">Chi tiết giỏ hàng <span> <a id="print" title="In trang này" onclick="javascript:window.print(); return false;" href="#">In trang này</a> <script type="text/javascript">addthis_pub = ''; addthis_logo = '';addthis_logo_background = 'EFEFFF';addthis_logo_color = '666699';addthis_brand = 'hangdientu.vn';addthis_options = 'facebook, myspace, twitter, google';</script><a href="http://www.addthis.com/bookmark.php" onmouseover="return addthis_open(this, '', '[URL]', '[TITLE]')" onmouseout="addthis_close()" onclick="return addthis_sendto()"><img src="<?php echo JURI::base(); ?> templates/wp_hangdientu/images/share.gif" width="16" height="16" border="0" alt="" /></a><script type="text/javascript" src="http://s7.addthis.com/js/152/addthis_widget.js"></script> </span> </h1> <div id="module_center"> <?php if ($Cart->hasItems()) { ?> <form action="index.php" method="get"> <table id="cart">
function order() { global $option; $mainframe; //$user =& JFactory::getUser(); $name = JRequest::getVar('name'); $email = JRequest::getVar('email'); $address = JRequest::getVar('address'); $phone = JRequest::getVar('phone'); $component = JComponentHelper::getComponent('com_products'); $params = new JParameter($component->params); //$params = &JComponentHelper::getParams( 'com_products' ); //$params->get( 'headerpic' ); $to = $params->get('email_contact'); //$params =& $mainframe->getPageParameters('com_products'); if (trim($name) == '' || $phone == '' || $email == '') { $this->setRedirect('index.php?option=com_products&view=cart', 'Xin vui lòng nhập đủ thông tin'); return; } $row =& JTable::getInstance('order', 'Table'); if (!$row->bind(JRequest::get('post'))) { echo "<script> alert('" . $row->getError() . "');\r\n\t\t\t\twindow.history.go(-1); </script>\n"; exit; } $Cart = new Shopping_Cart('shopping_cart'); $row->cartinfo = 0; if ($Cart->hasItems()) { foreach ($Cart->getItems() as $id => $cart) { $row->cartinfo .= $cart['name'] . ' x ' . $cart['count'] . '<br/>'; } } $row->userid = 0; if (!$row->store()) { echo "<script> alert('" . $row->getError() . "');\r\n\t\t\twindow.history.go(-1); </script>\n"; exit; } //send email //$to = '*****@*****.**'; $name = JRequest::getVar('name'); $email = JRequest::getVar('email'); $message1 = JRequest::getVar('message', ''); $product = $row->cartinfo; $date = date("h:i:s A', l, d/m/Y"); // To send HTML mail, the Content-type header must be set $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=utf-8' . "\r\n"; // Additional headers $headers .= 'To: <' . $to . '>' . "\r\n"; $headers .= 'From: HANGDIENTU.vn <' . $to . '>' . "\r\n"; $message .= JText::_('Địa chỉ: ') . $address . "\r\n"; $message .= JRequest::getVar('message'); $subject = $name; // Mail it mail($to, $subject, $message, $headers); // send den cho khach hang if (!empty($email)) { mail($email, $subject, $message, $headers); } session_unregister($Cart->cart_name); session_unregister($Cart->items); //session_destroy(); $this->setRedirect('index.php', 'Cảm ơn bạn đã đặt hàng của chúng tôi - Chúng tôi sẽ liên hệ với bạn sớm'); }