当前位置: 首页>>代码示例>>PHP>>正文


PHP Shop::getCartContent方法代码示例

本文整理汇总了PHP中Shop::getCartContent方法的典型用法代码示例。如果您正苦于以下问题:PHP Shop::getCartContent方法的具体用法?PHP Shop::getCartContent怎么用?PHP Shop::getCartContent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Shop的用法示例。


在下文中一共展示了Shop::getCartContent方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: actionCreate

 public function actionCreate()
 {
     if (!is_numeric($_POST['amount']) || $_POST['amount'] <= 0) {
         Shop::setFlash(Shop::t('Illegal amount given'));
         $this->redirect(array('//shop/products/view', 'id' => $_POST['product_id']));
     }
     if (isset($_POST['Variations'])) {
         foreach ($_POST['Variations'] as $key => $variation) {
             $specification = ProductSpecification::model()->findByPk($key);
             if ($specification->required && $variation[0] == '') {
                 Shop::setFlash(Shop::t('Please select a {specification}', array('{specification}' => $specification->title)));
                 $this->redirect(array('//shop/products/view', 'id' => $_POST['product_id']));
             }
         }
     }
     $cart = Shop::getCartContent();
     // remove potential clutter
     if (isset($_POST['yt0'])) {
         unset($_POST['yt0']);
     }
     if (isset($_POST['yt1'])) {
         unset($_POST['yt1']);
     }
     $cart[] = $_POST;
     Shop::setCartcontent($cart);
     Shop::setFlash(Shop::t('The product has been added to the shopping cart'));
     $this->redirect(array('//shop/products/index'));
 }
开发者ID:huynhchanhuy,项目名称:yii_shopping,代码行数:28,代码来源:ShoppingCartController.php

示例2: run

 public function run()
 {
     if (!Shop::getCartContent()) {
         return false;
     }
     $this->render('shopping_cart', array('products' => Shop::getCartContent()));
     return parent::run();
 }
开发者ID:rinodung,项目名称:yii-shop,代码行数:8,代码来源:ShoppingCartWidget.php

示例3: getPriceTotal

 public static function getPriceTotal()
 {
     $price_total = 0;
     $tax_total = 0;
     foreach (Shop::getCartContent() as $product) {
         $model = Products::model()->findByPk($product['product_id']);
         $price_total += $model->getPrice(@$product['Variations'], @$product['amount']);
         $tax_total += $model->getTaxRate(@$product['Variations'], @$product['amount']);
     }
     if ($shipping_method = Shop::getShippingMethod()) {
         $price_total += $shipping_method->price;
     }
     $price_total = Shop::t('Price total: {total}', array('{total}' => Shop::priceFormat($price_total)));
     $price_total .= '<br />';
     $price_total .= Shop::t('All prices are including VAT: {vat}', array('{vat}' => Shop::priceFormat($tax_total))) . '<br />';
     $price_total .= Shop::t('All prices excluding shipping costs') . '<br />';
     return $price_total;
 }
开发者ID:huynhchanhuy,项目名称:yii_shopping,代码行数:18,代码来源:Shop.php

示例4: array

<?php

Shop::register('css/shop.css');
if ($this->id == 'shoppingCart') {
    $this->renderPartial('/order/waypoint', array('point' => 0));
}
if (!isset($products)) {
    $products = Shop::getCartContent();
}
if (!isset($this->breadcrumbs) || $this->breadcrumbs == array()) {
    $this->breadcrumbs = array(Shop::t('Shop') => array('//shop/products/'), Shop::t('Shopping Cart'));
}
?>

<h2><?php 
echo Shop::t('Shopping cart');
?>
</h2>


<?php 
if ($products) {
    echo '<table cellpadding="0" cellspacing="0" class="shopping_cart">';
    printf('<tr><th>%s</th><th>%s</th><th>%s</th><th>%s</th><th style="width:60px;">%s</th><th style="width:60px;">%s</th><th>%s</th></tr>', Shop::t('Image'), Shop::t('Amount'), Shop::t('Product'), Shop::t('Variation'), Shop::t('Price Single'), Shop::t('Sum'), Shop::t('Actions'));
    //var_dump($products);die();
    foreach ($products as $position => $product) {
        if ($model = Products::model()->findByPk($product['product_id'])) {
            $variations = '';
            if (isset($product['Variations'])) {
                foreach ($product['Variations'] as $specification => $variation) {
                    if ($specification = ProductSpecification::model()->findByPk($specification)) {
开发者ID:axetion007,项目名称:yii-shop,代码行数:31,代码来源:view.php

示例5: actionConfirm

 public function actionConfirm()
 {
     Yii::app()->user->setState('order_comment', @$_POST['Order']['Comment']);
     if (isset($_POST['accept_terms']) && $_POST['accept_terms'] == 1) {
         $order = new Order();
         $customer = Shop::getCustomer();
         $cart = Shop::getCartContent();
         $order->customer_id = $customer->customer_id;
         $address = new DeliveryAddress();
         if ($customer->deliveryAddress) {
             $address->attributes = $customer->deliveryAddress->attributes;
         } else {
             $address->attributes = $customer->address->attributes;
         }
         $address->save();
         $order->delivery_address_id = $address->id;
         $address = new BillingAddress();
         if ($customer->billingAddress) {
             $address->attributes = $customer->billingAddress->attributes;
         } else {
             $address->attributes = $customer->address->attributes;
         }
         $address->save();
         $order->billing_address_id = $address->id;
         $order->ordering_date = time();
         $order->payment_method = Yii::app()->user->getState('payment_method');
         $order->shipping_method = Yii::app()->user->getState('shipping_method');
         $order->comment = Yii::app()->user->getState('order_comment');
         $order->status = 'new';
         if ($order->save()) {
             foreach ($cart as $position => $product) {
                 $position = new OrderPosition();
                 $position->order_id = $order->order_id;
                 $position->product_id = $product['product_id'];
                 $position->amount = $product['amount'];
                 $position->specifications = json_encode($product['Variations']);
                 $position->save();
             }
             Shop::mailNotification($order);
             Shop::flushCart(true);
             if (Shop::module()->payPalMethod !== false && $order->payment_method == Shop::module()->payPalMethod) {
                 $this->redirect(array(Shop::module()->payPalUrl, 'order_id' => $order->order_id));
             } else {
                 $this->redirect(Shop::module()->successAction);
             }
         }
         $this->redirect(Shop::module()->failureAction);
     } else {
         Shop::setFlash(Shop::t('Please accept our Terms and Conditions to continue'));
         $this->redirect(array('//shop/order/create'));
     }
 }
开发者ID:rinodung,项目名称:yii-shop,代码行数:52,代码来源:OrderController.php

示例6: array

<?php

$this->renderPartial('/order/waypoint', array('point' => 4));
$this->breadcrumbs = array(Shop::t('Order') => array('index'), Shop::t('New Order'));
?>

<?php 
Shop::renderFlash();
echo CHtml::beginForm(array('//shop/order/confirm'));
echo '<h2>' . Shop::t('Confirmation') . '</h2>';
if (Shop::getCartContent() == array()) {
    return false;
}
// If the customer is not passed over to the view, we assume the user is
// logged in and we fetch the customer data from the customer table
if (!isset($customer)) {
    $customer = Shop::getCustomer();
}
$this->renderPartial('application.modules.shop.views.customer.view', array('model' => $customer, 'hideAddress' => true, 'hideEmail' => true));
echo '<br />';
echo '<hr />';
echo '<p>';
$shipping = ShippingMethod::model()->find('id = :id', array(':id' => Yii::app()->user->getState('shipping_method')));
echo '<strong>' . Shop::t('Shipping Method') . ': </strong>' . ' ' . $shipping->title . ' (' . $shipping->description . ')';
echo '<br />';
echo CHtml::link(Shop::t('Edit shipping method'), array('//shop/shippingMethod/choose', 'order' => true));
echo '</p>';
echo '<p>';
$payment = PaymentMethod::model()->findByPk(Yii::app()->user->getState('payment_method'));
echo '<strong>' . Shop::t('Payment method') . ': </strong>' . ' ' . $payment->title . ' (' . $payment->description . ')';
echo '<br />';
开发者ID:axetion007,项目名称:yii-shop,代码行数:31,代码来源:create.php

示例7: actionCreate

 public function actionCreate()
 {
     if (!is_numeric($_POST['amount']) || $_POST['amount'] <= 0) {
         Shop::setFlash(Shop::t('Illegal amount given'));
         $this->redirect(array('//shop/products/view', 'id' => $_POST['product_id']));
     }
     if (isset($_POST['Variations'])) {
         foreach ($_POST['Variations'] as $key => $variation) {
             $specification = ProductSpecification::model()->findByPk($key);
             if ($specification->required && $variation[0] == '') {
                 Shop::setFlash(Shop::t('Please select a {specification}', array('{specification}' => $specification->title)));
                 $this->redirect(array('//shop/products/view', 'id' => $_POST['product_id']));
             }
         }
     }
     if (isset($_FILES)) {
         foreach ($_FILES as $variation) {
             $target = Shop::module()->uploadedImagesFolder . '/' . $variation['name'];
             if ($variation['tmp_name'] == '') {
                 Shop::setFlash(Shop::t('Please select a image from your hard drive'));
                 $this->redirect(array('//shop/shoppingCart/view'));
             }
             if (move_uploaded_file($variation['tmp_name'], $target)) {
                 $_POST['Variations']['image'] = $target;
             }
         }
     }
     $cart = Shop::getCartContent();
     // remove potential clutter
     if (isset($_POST['yt0'])) {
         unset($_POST['yt0']);
     }
     if (isset($_POST['yt1'])) {
         unset($_POST['yt1']);
     }
     $cart[] = $_POST;
     Shop::setCartcontent($cart);
     Shop::setFlash(Shop::t('The product has been added to the shopping cart'));
     $this->redirect(array('//shop/shoppingCart/view'));
 }
开发者ID:axetion007,项目名称:yii-shop,代码行数:40,代码来源:ShoppingCartController.php


注:本文中的Shop::getCartContent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。