コード例 #1
0
ファイル: raw.php プロジェクト: geilin/jooomlashop
<?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>';
    }
コード例 #2
0
ファイル: product.php プロジェクト: geilin/jooomlashop
 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');
 }