Esempio n. 1
0
 public function loadModel()
 {
     if ($this->_model === null) {
         if (isset($_GET['product'])) {
             $this->_model = product_entity::model()->findByAttributes(array('product_SEF' => $_GET['product']));
         }
         if ($this->_model === null) {
             throw new CHttpException(404, 'The requested page does not exist.');
         }
     }
     return $this->_model;
 }
Esempio n. 2
0
 public function actionPayment()
 {
     $cart = cart::model()->findByPk(Yii::app()->user->getState('cart_ID'));
     if (!$cart->cart_address_ID or !$cart->cart_carrier_ID) {
         $this->redirect(array('index'));
         exit;
     }
     if (!($address = address_entity::model()->findByPk($cart->cart_address_ID))) {
         $this->redirect(array('index'));
         exit;
     }
     $grandTotal = product_entity::decoratePrice($cart->getOrderTotal(), true);
     $this->render('payment', array('grandTotal' => $grandTotal));
 }
Esempio n. 3
0
 public function actionView()
 {
     $model = $this->loadModel();
     if ($model->seo) {
         $this->installMeta($model->seo->attributes);
     }
     $criteria = new CDbCriteria(array('condition' => 'm2.category_ID =' . $model->category_ID, 'join' => 'left join {{category_product}} as m2 ON t.product_ID=m2.product_ID', 'order' => 'product_update DESC'));
     $view = 'view';
     $count = product_entity::model()->count($criteria);
     $pages = new CPagination($count);
     $pages->pageSize = 20;
     $pages->applyLimit($criteria);
     $dataProvider = new CActiveDataProvider('product_entity', array('pagination' => $pages, 'criteria' => $criteria));
     $this->render('view', array('model' => $model, 'dataProvider' => $dataProvider));
 }
Esempio n. 4
0
 public function checkDiscounts($orderTotal)
 {
     if (!$orderTotal > 0) {
         cart_discount::model()->deleteAllByAttributes(array('cart_ID' => $this->cart_ID));
         return;
     }
     if (sizeof($discounts = cart_discount::items($this->cart_ID)) >= 1) {
         foreach ($discounts as $discount) {
             $minimal = product_entity::decoratePrice($discount['discount_minmal']);
             if ($orderTotal < $minimal) {
                 cart_discount::model()->deleteAllByAttributes(array('cart_ID' => $this->cart_ID, 'discount_ID' => $discount['discount_ID']));
                 break;
             }
             if (!$discount['discount_active'] == 1 or !$discount['discount_quantity']) {
                 cart_discount::model()->deleteAllByAttributes(array('cart_ID' => $this->cart_ID, 'discount_ID' => $discount['discount_ID']));
                 break;
             }
             if (strtotime($discount['discount_from']) > time() or strtotime($discount['discount_to']) < time()) {
                 cart_discount::model()->deleteAllByAttributes(array('cart_ID' => $this->cart_ID, 'discount_ID' => $discount['discount_ID']));
                 break;
             }
             if ($this->nbDiscounts($discount['discount_ID']) >= $discount['discount_quantity_per_user'] or order_discount::nbDiscountCustomer(Yii::app()->user->getId(), $discount['discount_ID']) + $this->nbDiscounts($discount['discount_ID']) >= $discount['discount_quantity_per_user']) {
                 cart_discount::model()->deleteAllByAttributes(array('cart_ID' => $this->cart_ID, 'discount_ID' => $discount['discount_ID']));
                 break;
             }
             $onlyProductWithDiscount = true;
             if (!$discount['discount_cumulable_reduction'] == 1) {
                 foreach ($this->products as $product) {
                     if (!intval($product['product_reducetion_price']) and !intval($product['product_reducetion_percent'])) {
                         $onlyProductWithDiscount = false;
                         break;
                     }
                 }
             }
             if (!$discount['discount_cumulable_reduction'] == 1 and $onlyProductWithDiscount) {
                 cart_discount::model()->deleteAllByAttributes(array('cart_ID' => $this->cart_ID, 'discount_ID' => $discount['discount_ID']));
                 break;
             }
         }
     }
     return;
 }
Esempio n. 5
0
                    <thead>
                        <tr>
                            <th width="7%"></th>
                            <th width="25%">Shipping Method</th>
                            <th width="43%">Shipping Infromation</th>
                            <th width="25%">Shipping Price</th>
                        </tr>
                    </thead>
                    <tbody>
                        <?php 
foreach ($carrier as $row) {
    $select = '';
    if ($row['selected']) {
        $select = 'checked';
    }
    $price = product_entity::decoratePrice($row['price'], true);
    echo "  <tr>\n                            <td><input type='radio' name='carrier' value='{$row['carrier_ID']}' {$select}/></td>\n                            <td>{$row['carrier_name']}</td>\n                            <td>{$row['carrier_description']}</td>\n                            <td><span class='orange fw700'>{$price}</span></td>\n                             <tr>";
}
?>
                    </tbody>
                </table>
       
            <div class="sunmm_box" style="background-color:#f8f8f8; padding:6px;">
                <div class="fl mt_10"><a href="/">&laquo; continue to shopping</a></div>
                <div class="fr">   <?php 
echo CHtml::submitButton('', array('class' => 'button ubutton button_checkstep'));
?>
</div>
                <div class="fix"></div>
            </div>
     </form>
Esempio n. 6
0
<div class="side_box mb_12 side_deals">
    <div class="side_title">Daily Deals</div>
    <div class="side_deals_box">
        <ul class="nav2">
            <?php 
foreach (product_entity::model()->daliy(4)->findAll() as $row) {
    echo <<<HTML
<li>
 <a class="p_l_img" href="{$row->getUrl()}"><img alt="{$row->gallery->base->image_label}" src="{$row->gallery->base->getSmall()}"></a>
                      <div>
                    <a class="p_l_title" href="{$row->getUrl()}">{$row->product_name}</a>
                     <span class='p_l_desc'>{$row->product_short_description}</span>
                    <span class="linegray">\${$row->getRegularPrice()}</span><span class="orange">\${$row->getSpecialPrice()}</span></div>
                    <a class="button button_cart_m mt_10" href="/product/cart/id/{$row->product_ID}/qty/{$row->stock->stock_min_qty_cart}"></a>
                   <a class="button button_checko_m mt_10 ml_6" href="/product/checkout/id/{$row->product_ID}/qty/{$row->stock->stock_min_qty_cart}"></a>
               
 </li>

HTML;
}
?>

           </ul>
        <div class="fix"></div>
    </div>
</div>


Esempio n. 7
0
$grandTotal = $cart->getOrderTotal();
if (!$cart->isFreeshipping()) {
    $remain = product_entity::decoratePrice(configuration::item('SHIPPING', 'SHIPPING_FREE_PRICE') - $grandTotal, true);
    echo " <p style='margin-top: 3px; display: inline;'>Remaining amount to be added to your cart in order to obtain free shipping: <span class='green'>{$remain}</span></p>";
    if ($cart->cart_carrier_ID && $cart->cart_address_ID) {
        $shippingFee = product_entity::decoratePrice($cart->getOrderTotal(5), true);
        echo " <strong class='t_c1'>Total Shipping:<span class='red'>{$shippingFee}</span></strong>";
    }
} else {
    echo "<p style='margin-top: 3px; display: inline;'>You have obtain free shipping</p>";
}
?>
                    </div>

                    <div class="ar t_count">
                        <?php 
echo CHtml::dropDownList('currency', Yii::app()->user->getState('currency_ID'), currency::getCurrencies());
?>
                       
                        <strong class="t_c1">GrandTotal:<span class="red"><?php 
echo product_entity::decoratePrice($grandTotal, true);
?>
</span></strong>
            </div>
            <div class="fl mt_10"><a href="/">&laquo; continue to shopping</a></div>
            <p class="ar"><input  type="button"  value="" id="check_btn" class="button ubutton button_checkstep " /></p>
        </div>
        <div class="fix"></div>
    </div>
</div>
Esempio n. 8
0
</div>

<div class="content_box mb_12 prduct_list">
    <h2>Newarrival nds card</h2>

   <?php 
$this->widget('TradeList', array('dataProvider' => new CActiveDataProvider('product_entity', array('criteria' => product_entity::model()->latest(12))), 'itemView' => '_product', 'template' => "{items}"));
?>

    <div class="fix"></div>
</div>

<div class="content_box mb_12 prduct_list">
    <h2>Featured Products</h2>
      <?php 
$this->widget('TradeList', array('dataProvider' => new CActiveDataProvider('product_entity', array('criteria' => product_entity::model()->feature())), 'itemView' => '_product', 'template' => "{items}"));
?>
   
    <div class="fix"></div>
</div>

<div class="content_box mb_12 index_desc" id="i_tabs">

    <h2><a href="javascript://;" class="i_d_sel">Why Us</a> <a href="javascript://;">Guarantee</a> <a href="javascript://;" class="i_d_last">Professional Service</a></h2>

    <div class="i_d_box  i_d_box1">
        <img src="/images/index_help_icon1.gif" alt="" />
        <p> In recent years competition has grown rapidly and with so many companies to choose from,Why us?
            CARDSNDS.COM tries to integrate the industry resource to provide our customer
            all the accessories for the most popular Video Game consoles: Nintendo Wii, Microsoft XBox 360, Sony PSP, Sony PlayStation 3, Nintendo DS, Nintendo GBA, and more,
            at the most preferential price, reliable quality and considerate service.
Esempio n. 9
0
 public function loadModel()
 {
     if ($this->_model == null) {
         if (isset($_GET['id'])) {
             $condition = '';
             $this->_model = product_entity::model()->findByPk($_GET['id'], $condition);
         }
         if ($this->_model == null) {
             throw new CHttpException(404, "The requested page does not exist!");
         }
     }
     return $this->_model;
 }
Esempio n. 10
0
 public function validateOrder($cart_ID, $order_status, $amountPaid, $paymentMethod = 'Unknown', $message = NULL, $extraVars = array(), $currency_special = NULL, $dont_touch_amount = false)
 {
     $cart = cart::model()->findByPk(intval($cart_cart));
     if ($cart and !$cart->orderExists()) {
         $order = new order_entity();
         $customer = customer_entity::model()->findByPk($cart->cart_customer_ID);
         $currency = currency::model()->findByPK($cart->cart_currency_ID);
         $order->order_carrier_ID = intval($cart->cart_carrier_ID);
         $order->order_address_ID = intval($cart->cart_address_ID);
         $order->order_cart_ID = intval($cart->cart_ID);
         $order->order_currency_ID = intval($cart->cart_currency_ID);
         $order->order_customer_ID = intval($cart->cart_customer_ID);
         $order->order_salt = $customer->customer_salt;
         $order->order_payment_method = $paymentMethod;
         $amountPaid = !$dont_touch_amount ? round(floatval($amountPaid), 2) : $amountPaid;
         $order->order_total_paid = $amountPaid;
         $order->order_total_discount = product_entity::decoratePrice($cart->getOrderTotal(2));
         $order->order_total_products = product_entity::decoratePrice($cart->getOrderTotal(1));
         $order->order_total_shipping = product_entity::decoratePrice($cart->getOrderShippingCost());
         $order->order_grand = product_entity::decoratePrice($cart->getOrderTotal());
         $order->order_delivery_ID = 0;
         $order->order_payment_date = date('Y-m-d H:i:s');
         $order->order_delivery_date = '0000-00-00 00:00:00';
         if ($order->order_total_paid < $order->order_grand) {
             $order_status = order_entity::PaymentError;
         }
         $order->order_status = $order_status;
         $res = $order->save();
         if ($res and $order->order_ID) {
             //order detail
             foreach ($cart->products as $product) {
                 $quantity = $cart->containProduct($row->product_ID);
                 $orderDetail = new order_detail();
                 $orderDetail->detail_order_ID = $order->order_ID;
                 $orderDetail->detail_product_ID = $product->product_ID;
                 $orderDetail->detail_product_name = $product->product_name;
                 if ($quantity['quantity'] > 1) {
                     $discount_ID = discount_quantity::validateQuantityDiscount($product->product_ID, $quantity['quantity']);
                     if ($discount_ID) {
                         $discountQuantity = discount_quantity::model()->findByPk($discount_ID);
                         $orderDetail->detail_quantity_discount = $currency->convert($product->product_price - $discountQuantity->applyRule($product->product_price));
                         $orderDetail->detail_quantity_discount_applied = 1;
                         $orderDetail->detail_reducetion_percent = 0;
                         $orderDetail->detail_reducetion_amount = 0;
                         $orderDetail->detail_product_price = $currency->convert($product->product_price - $orderDetail->detail_quantity_discount);
                     }
                 } else {
                     if ($product->isReduction()) {
                         if ($product->product_reducetion_percent) {
                             $orderDetail->detail_reducetion_percent = $currency->convert(floatval($product->product_price) * floatval($product->product_reducetion_percent / 100), 2);
                             $orderDetail->detail_reducetion_amount = 0;
                             $orderDetail->detail_quantity_discount = 0;
                             $orderDetail->detail_quantity_discount_applied = 2;
                             $orderDetail->detail_product_price = $currency->convert($product->product_price - $orderDetail->detail_reducetion_percent);
                         } else {
                             $orderDetail->detail_reducetion_amount = $currency->convert($product->product_reducetion_amount);
                             $orderDetail->detail_reducetion_percent = 0;
                             $orderDetail->detail_quantity_discount = 0;
                             $orderDetail->detail_quantity_discount_applied = 2;
                             $orderDetail->detail_product_price = $currency->convert($product->product_price - $orderDetail->detail_reducetion_amount);
                         }
                     } else {
                         $orderDetail->detail_reducetion_amount = 0;
                         $orderDetail->detail_reducetion_percent = 0;
                         $orderDetail->detail_quantity_discount = 0;
                         $orderDetail->detail_quantity_discount_applied = 2;
                         $orderDetail->detail_product_price = $currency->convert($product->product_price);
                     }
                 }
                 $orderDetail->order_weight = floatval($product->product_weight);
                 $orderDetail->save();
                 //update product info
                 if ($order->order_status != order_entity::PaymentError and $order->order_status != order_entity::Canceled) {
                     $product->product_quantity -= $quantity['quantity'];
                     $product->save();
                 }
             }
             //order_discount
             if (sizeof($discounts = cart_discount::items($cart->cart_ID)) >= 1) {
                 foreach ($discounts as $discount) {
                     $orderDiscount = new order_discount();
                     $orderDiscount->order_ID = $order->order_ID;
                     $orderDiscount->discount_ID = $discount['discount_ID'];
                     $orderDiscount->discount_name = $discount['discount_name'];
                     if ($discount['discount_type'] == 3) {
                         $orderDiscount->discount_value = 0;
                     } else {
                         if ($discount['discount_type'] == 2) {
                             $orderDiscount->discount_value = $currency->convert($discount['discount_value']);
                         } else {
                             if ($discounts['discount_type'] == 1) {
                                 $orderDiscount->discount_value = $currency->convert($order->order_total_products * ($discount['discount_value'] / 100));
                             }
                         }
                     }
                 }
             }
             /**
              * To do list
              * 1.Email confirm
              * 2.Product sales
              * 3.Order message
              * 4.order History
              *
              */
         }
     }
 }