if ($Cart->hasItems()) { ?> <form action="index.php" method="get"> <table id="cart"> <tr class="table-th"> <td>Sản Phẩm</td> <td>Số Lượng</td> <td>Xóa</td> <td>Cập Nhật</td> <td>Đơn Giá</td> <td>Thành Tiền</td> </tr> <?php $total_price = $total_price_vn = $i = 0; $cartinfo = ''; $carts = $Cart->getItems(); $soluong = count($carts); foreach ($carts as $id => $cart) { if ($cart['currency'] == 'USD') { $total_price += $cart['count'] * $cart['price']; } else { $total_price_vn += $cart['count'] * $cart['price']; } $cartinfo .= $cart['name'] . ' x ' . $cart['count'] . '<br/>'; $currency = $cart['currency']; //== 'USD' ? '$' : 'đ'; $i++; ?> <tr> <td>
* @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>'; } ?> </ul> <p class="total_price">Tổng cộng: <span id="total_price_vn_mod"><?php echo number_format($total_price_vn); ?> VNĐ</span></p>
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'); }