Example #1
0
 public function saveOrder()
 {
     $ShoppingCart = Kiwi::getShoppingCart();
     $this->user_id = Yii::$app->user->id;
     $this->total_price = $ShoppingCart->getTotal();
     /**@TODO attributes  * */
     $this->shipping_fee = $ShoppingCart->getShippingFee();
     $this->payment_fee = 0;
     $this->status = 1;
     $cartItems = $ShoppingCart->cartItems;
     $orderItems = [];
     foreach ($cartItems as $cartItem) {
         $key = $cartItem->data['key'];
         /** @var \extensions\sales\models\CustomerSales $customer_sale */
         $customerSaleClass = Kiwi::getCustomerSalesClass();
         $customer_sale = $customerSaleClass::find()->where(['key' => $key])->one();
         $orderItem = Kiwi::getOrderItem();
         $orderItem->item_id = $cartItem->item->item_id;
         $orderItem->price = $customer_sale->sale_price;
         $orderItem->qty = $cartItem->qty;
         $orderItem->name = $cartItem->item->name;
         $orderItem->data = $cartItem->data;
         /**@TODO picture can not null * */
         $orderItem->picture = is_null($cartItem->item->pictures) ? $cartItem->item->pictures : 'default';
         $orderItems[] = $orderItem;
     }
     $this->orderItems = $orderItems;
     if ($this->save()) {
         $ShoppingCart->clearAll();
         return true;
     }
     return false;
 }
Example #2
0
 public function actionClearAll()
 {
     if (Kiwi::getShoppingCart()->clearAll()) {
         echo Json::encode(['message' => 'remove success', 'redirect' => 'index']);
     } else {
         echo Json::encode(['message' => 'remove fail', 'redirect' => 'index']);
     }
 }
Example #3
0
    echo Html::img($item->pictures);
    ?>
        <?php 
    echo Html::textInput('[name]', $item->name, ['disabled' => true]);
    ?>
        <?php 
    echo Html::textInput('[price]', $item->price, ['disabled' => true]);
    ?>
        <?php 
    echo Html::textInput('[qty]', $cartItem->qty, ['disabled' => true]);
    ?>

    </div>
   <?php 
}
?>
    <?php 
echo Html::label(Yii::t('app', 'Price'), 'totalPrice');
?>
    <?php 
echo Html::textInput('totalPrice', Kiwi::getShoppingCart()->getTotal(), ['disabled' => true]);
?>
    <?php 
echo Html::button(Yii::t('app', 'Create order'), ['class' => 'btn btn-primary create-order', 'data-create' => true, 'data-url' => Url::to(['order/order-save'])]);
?>
    <?php 
echo Html::a(Yii::t('app', 'Cancel'), ['site/index']);
?>
</div>

Example #4
0
 /**
  * Lists all Order models.
  * @return mixed
  */
 public function actionIndex()
 {
     $cartItems = Kiwi::getShoppingCart()->cartItems;
     return $this->render('index', ['cartItems' => $cartItems]);
 }
Example #5
0
                        <?php 
    }
}
?>
                    <tr>
                        <td colspan="6" style="padding:10px;text-align:right">
                            运费:<?php 
echo Kiwi::getShoppingCart()->getShippingFee();
?>
 元
                        </td>
                    </tr>
                    <tr>
                        <td colspan="6" style="padding:10px;text-align:right">
                            总计:<?php 
echo Kiwi::getShoppingCart()->getTotal();
?>
 元
                        </td>
                    </tr>
                </table>

            </div>
            <div class="box-content">
                <div class="memo" style="float:left"><h3>
                        给卖家留言:</h3>
                    <textarea id="memo" name="memo" placeholder="选填,可以告诉卖家您对商品的特殊要求,如:颜色、尺码等" rows="5"></textarea>
                </div>
            </div>

            <div class="box-content">