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


PHP ShoppingCart类代码示例

本文整理汇总了PHP中ShoppingCart的典型用法代码示例。如果您正苦于以下问题:PHP ShoppingCart类的具体用法?PHP ShoppingCart怎么用?PHP ShoppingCart使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: Confirm

 /**
  * 
  */
 public function Confirm()
 {
     $auth = new Auth();
     $shop = new ShoppingCart();
     $user = $auth->id();
     $myShop = $shop->all();
     $objDetails = new DetalleCompra();
     $total = 0;
     if (empty($myShop)) {
         return false;
     }
     foreach ($myShop as $key => $val) {
         $total += $val->precio * $val->cantidad;
     }
     $result_insert = $this->create($user, $total);
     if ($result_insert->success) {
         foreach ($myShop as $k => $v) {
             try {
                 $objDetails->create($result_insert->id, $v->id_prod, $v->name, $v->cantidad, $v->precio, $v->talle, $v->color);
                 //$stock = new TempStock();
                 //echo $stock->removeTempStock($user,$v->id_prod,$v->id_talle,$v->id_color,$v->type);
             } catch (Exception $e) {
                 echo $e->getMessage();
             }
         }
         $auth->restPoints($total);
         $auth->sumConsumed($total);
         $shop->removeAll();
         return true;
     }
 }
开发者ID:EzequielDot175,项目名称:mknet,代码行数:34,代码来源:class.compras.php

示例2: render

 public function render()
 {
     if (isset($_POST["clearCart"])) {
         setcookie("shoppingCart", "");
     }
     if (isset($_GET["remove"])) {
         $myArray = json_decode($_COOKIE["shoppingCart"]);
         $i = 0;
         foreach ($myArray as $index) {
             if ($index->ID == $_GET["remove"]) {
                 unset($myArray[$i]);
                 $myArray = array_values($myArray);
                 break;
             }
             $i++;
         }
         setcookie("shoppingCart", json_encode($myArray));
     }
     $htmlcontent = "Der Warenkorb enthält keine Produkte";
     if (isset($_COOKIE["shoppingCart"])) {
         $myArray = json_decode($_COOKIE["shoppingCart"]);
         //$htmlcontent = $htmlcontent. "Warenkorb:" .print_r(array_values($myArray));
         include_once 'classes/class.shoppingcart.php';
         $myCart = new ShoppingCart($myArray);
         $htmlcontent = $myCart->displayCart();
     }
     return $htmlcontent;
 }
开发者ID:Makae,项目名称:ch.bfh.bti7054.w2014.q.groot,代码行数:28,代码来源:view.shoppingcart.php

示例3: testComputesReducedVatForTheRightCountry

 public function testComputesReducedVatForTheRightCountry()
 {
     $shoppingCart = new ShoppingCart(new Austria());
     $article = new Article(new ArticleName('Test'), new ArticleDescription(''), new Euro(1000), new ArticleTypeReduced());
     $shoppingCart->add($article);
     $shoppingCart->add($article);
     $this->assertEquals(new Money(2200, new Currency('EUR')), $shoppingCart->total());
 }
开发者ID:mihaeu,项目名称:PW-SimpleShop,代码行数:8,代码来源:ShoppingCartTest.php

示例4: createCartWithItems

 /**
  * Create a {@link ShoppingCart} object and give
  * it some test {@link OrderItem} objects.
  *
  * @return object ShoppingCart
  */
 public static function createCartWithItems()
 {
     $item1 = new ProductVariation_OrderItem(array('ProductVariationID' => 2, 'Version' => 1));
     $item2 = new ProductVariation_OrderItem(array('ProductVariationID' => 1, 'Version' => 1));
     $cart = new ShoppingCart();
     $cart->addItem(2, $item1);
     $cart->addItem(1, $item2);
     return $cart;
 }
开发者ID:halkyon,项目名称:silverstripe-ecommerce_experiment,代码行数:15,代码来源:ShoppingCartTest.php

示例5: actionAddToCart

 public function actionAddToCart($id)
 {
     $cart = new ShoppingCart();
     $model = Product::findOne($id);
     if ($model) {
         $cart->put($model, 1);
         return $this->redirect(['cart-view']);
     }
     throw new NotFoundHttpException();
 }
开发者ID:bokhonok-t,项目名称:yii2_e-shop,代码行数:10,代码来源:SiteController.php

示例6: checkPoints

 public function checkPoints()
 {
     $user = Auth::User();
     $ShoppingCart = new ShoppingCart();
     $ShoppingCart->all();
     $credit = $user->dblCredito;
     $total = $ShoppingCart->getTotal();
     if ($credit - $total < 0) {
         return false;
     } else {
         return true;
     }
 }
开发者ID:EzequielDot175,项目名称:mknet,代码行数:13,代码来源:class.usuario.php

示例7: setStoreInfo

function setStoreInfo($storeID, $storeInfo)
{
    if (class_exists("ShoppingCart")) {
        $Store = new ShoppingCart();
        $Store->setStoreID($storeID);
        $storeInfo = $Store->getStoreInformation();
        return $storeInfo;
    } else {
        $ErrorMsgs[] = "The ShoppingCart class is not available!";
        echo '<p>' . $ErrorMsgs[0] . '</p>';
        return NULL;
    }
}
开发者ID:azaeng04,项目名称:ip3shoppingcartazatra,代码行数:13,代码来源:home-main.php

示例8: afterLogin

 protected function afterLogin($fromCookie)
 {
     if (!$fromCookie) {
         // Assign the user to the cart, if logged in
         Yii::app()->shoppingcart->assignCustomer(Yii::app()->user->id);
         // If the user is not a guest user, then update the tax destination
         // for the user's cart to display correct product prices. We can't
         // do this for guest users since it will reset their cart to the
         // store default, which is generally not what we want, especially
         // not in tax-inclusive environments when the shipping destination
         // is in a notax region.
         if ($this->getIsGuest() !== true) {
             Yii::app()->shoppingcart->setTaxCodeByDefaultShippingAddress();
         }
         // Since we have successfully logged in, see if we have a cart in progress
         $cartInProgressFound = Yii::app()->shoppingcart->loginMerge();
         // Recalculate and update the cart if prices of any cart items have changed
         if ($cartInProgressFound === true) {
             Yii::app()->shoppingcart->verifyPrices();
             Yii::log("Cart ID is " . Yii::app()->shoppingcart->id, 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
         }
         // Display no-tax message if the customer's default shipping address is
         // in no-tax destination in tax-inclusive mode
         if (Yii::app()->params['TAX_INCLUSIVE_PRICING'] == 1) {
             ShoppingCart::displayNoTaxMessage();
         }
     } else {
         Yii::log("User Login using cookie", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
     }
 }
开发者ID:uiDeveloper116,项目名称:webstore,代码行数:30,代码来源:WebUser.php

示例9: testCalculations

 function testCalculations()
 {
     $mp3player = $this->objFromFixture('Product', 'mp3player');
     $this->get(ShoppingCart::add_item_link($mp3player->ID));
     $cart = ShoppingCart::current_order();
     $this->assertEquals($cart->Total(), 215);
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:7,代码来源:FlatTaxModifierTest.php

示例10: doAddItemToCart

 public function doAddItemToCart($data)
 {
     $product = Product::get()->byID($data['ProductID']);
     $customisations = array();
     foreach ($data as $key => $value) {
         if (!(strpos($key, 'customise') === false) && $value) {
             $custom_data = explode("_", $key);
             if ($custom_item = ProductCustomisation::get()->byID($custom_data[1])) {
                 $modify_price = 0;
                 // Check if the current selected option has a price modification
                 if ($custom_item->Options()->exists()) {
                     $option = $custom_item->Options()->filter("Title", $value)->first();
                     $modify_price = $option ? $option->ModifyPrice : 0;
                 }
                 $customisations[] = array("Title" => $custom_item->Title, "Value" => $value, "ModifyPrice" => $modify_price);
             }
         }
     }
     if ($product) {
         $cart = ShoppingCart::create();
         $cart->add($product, $data['Quantity'], $customisations);
         $cart->save();
         // Clear any postage data that has been set
         Session::clear("Commerce.PostageID");
         $message = _t('Commerce.AddedItemToCart', 'Added item to your shopping cart');
         $message .= ' <a href="' . $cart->Link() . '">';
         $message .= _t('Commerce.ViewCart', 'View cart');
         $message .= '</a>';
         $this->controller->setSessionMessage("success", $message);
     }
     return $this->controller->redirectBack();
 }
开发者ID:helpfulrobot,项目名称:i-lateral-silverstripe-commerce,代码行数:32,代码来源:AddItemToCartForm.php

示例11: checkoutconfig

 protected function checkoutconfig()
 {
     $config = new CheckoutComponentConfig(ShoppingCart::curr(), true);
     $config->addComponent($comp = new CouponCheckoutComponent());
     $comp->setValidWhenBlank(true);
     return $config;
 }
开发者ID:helpfulrobot,项目名称:silvershop-discounts,代码行数:7,代码来源:CheckoutStep_Discount.php

示例12: dopayment

 function dopayment($data, $form)
 {
     $SQLData = Convert::raw2sql($data);
     if (isset($SQLData['OrderID'])) {
         if ($orderID = intval($SQLData['OrderID'])) {
             $order = Order::get_by_id_if_can_view($orderID);
             if ($order && $order->canPay()) {
                 if (EcommercePayment::validate_payment($order, $form, $data)) {
                     $payment = EcommercePayment::process_payment_form_and_return_next_step($order, $form, $data);
                 }
                 if ($payment) {
                     ShoppingCart::singleton()->submit();
                     $order->tryToFinaliseOrder();
                     return $payment;
                 } else {
                     //error messages are set in validation
                     return $this->controller->redirectBack();
                 }
             } else {
                 $form->sessionMessage(_t('OrderForm.NO_PAYMENTS_CAN_BE_MADE_FOR_THIS_ORDER', 'No payments can be made for this order.'), 'bad');
                 return $this->controller->redirectBack();
             }
         }
     }
     $form->sessionMessage(_t('OrderForm.COULDNOTPROCESSPAYMENT', 'Sorry, we could not find the Order for payment.'), 'bad');
     $this->controller->redirectBack();
     return false;
 }
开发者ID:TouchtechLtd,项目名称:silverstripe-ecommerce,代码行数:28,代码来源:OrderForm_Payment.php

示例13: testProductVersionDoesNotExist

 /**
  * Tries to create an order item with a non-existent version.
  */
 function testProductVersionDoesNotExist()
 {
     $currentorder = ShoppingCart::current_order();
     $brokenitem = new Product_OrderItem(array("ProductID" => $productSocks->ID, "ProductVersion" => 99999));
     $this->assertEquals($brokenitem->UnitPrice(), null);
     //TODO: what should happen here???
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:10,代码来源:ProductOrderItemTest.php

示例14: memberLoggedOut

 /**
  * Clear the cart, and session variables on member logout
  */
 public function memberLoggedOut()
 {
     if (Member::config()->login_joins_cart) {
         ShoppingCart::singleton()->clear();
         OrderManipulation::clear_session_order_ids();
     }
 }
开发者ID:burnbright,项目名称:silverstripe-shop,代码行数:10,代码来源:ShopMember.php

示例15: addtocart

 /**
  * Handles form submission
  * @param array $data
  * @return bool|\SS_HTTPResponse
  */
 public function addtocart(array $data)
 {
     $groupedProduct = $this->getController()->data();
     if (empty($data) || empty($data['Product']) || !is_array($data['Product'])) {
         $this->sessionMessage(_t('GroupedCartForm.EMPTY', 'Please select at least one product.'), 'bad');
         $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
         return $response ? $response : $this->controller->redirectBack();
     }
     $cart = ShoppingCart::singleton();
     foreach ($data['Product'] as $id => $prodReq) {
         if (!empty($prodReq['Quantity']) && $prodReq['Quantity'] > 0) {
             $prod = Product::get()->byID($id);
             if ($prod && $prod->exists()) {
                 $saveabledata = !empty($this->saveablefields) ? Convert::raw2sql(array_intersect_key($data, array_combine($this->saveablefields, $this->saveablefields))) : $prodReq;
                 $buyable = $prod;
                 if (isset($prodReq['Attributes'])) {
                     $buyable = $prod->getVariationByAttributes($prodReq['Attributes']);
                     if (!$buyable || !$buyable->exists()) {
                         $this->sessionMessage("{$prod->InternalItemID} is not available with the selected options.", "bad");
                         $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
                         return $response ? $response : $this->controller->redirectBack();
                     }
                 }
                 if (!$cart->add($buyable, (int) $prodReq['Quantity'], $saveabledata)) {
                     $this->sessionMessage($cart->getMessage(), $cart->getMessageType());
                     $this->extend('updateErrorResponse', $this->request, $response, $groupedProduct, $data, $this);
                     return $response ? $response : $this->controller->redirectBack();
                 }
             }
         }
     }
     $this->extend('updateGroupCartResponse', $this->request, $response, $groupedProduct, $data, $this);
     return $response ? $response : ShoppingCart_Controller::direct($cart->getMessageType());
 }
开发者ID:helpfulrobot,项目名称:markguinn-silverstripe-shop-groupedproducts,代码行数:39,代码来源:GroupedCartForm.php


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