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


PHP ShoppingCart::clear方法代码示例

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


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

示例1: clearandlogout

 /**
  * @param SS_HTTPRequest
  * @return REDIRECT
  **/
 function clearandlogout(SS_HTTPRequest $request)
 {
     $this->cart->clear();
     if ($member = Member::currentUser()) {
         $member->logout();
     }
     $this->redirect(Director::baseURL());
     return array();
 }
开发者ID:helpfulrobot,项目名称:sunnysideup-ecommerce,代码行数:13,代码来源:ShoppingCart_Controller.php

示例2: setUp

 function setUp()
 {
     parent::setUp();
     EcommerceTest::setConfiguration();
     Order::set_modifiers(array("FlatTaxModifer"), true);
     FlatTaxModifier::set_tax(0.15, "GST", true);
     $this->objFromFixture('Product', 'mp3player')->publish('Stage', 'Live');
     ShoppingCart::clear();
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:9,代码来源:FlatTaxModifierTest.php

示例3: testRemoveFromCart

 function testRemoveFromCart()
 {
     /* Retrieve the product to compare from fixture */
     $product = $this->objFromFixture('Product', 'mp3player');
     $anotherproduct = $this->objFromFixture('Product', 'tshirt');
     /* add items via url */
     $this->get(ShoppingCart::set_quantity_item_link($product->ID, $product->class) . "?quantity=5");
     $this->get(ShoppingCart::add_item_link($anotherproduct->ID, $product->class));
     /* remove items via url */
     $this->get(ShoppingCart::remove_item_link($product->ID, $product->class));
     $this->get(ShoppingCart::remove_item_link($anotherproduct->ID, $product->class));
     $items = ShoppingCart::get_items();
     $this->assertEquals($items->Count(), 1, 'There is 1 item in the cart');
     $this->assertEquals($items->First()->Quantity, 4, 'We have 4 mp3 players in the cart.');
     ShoppingCart::clear();
     //test clearing cart
     $this->assertEquals(ShoppingCart::get_items(), null, 'Cart is clear');
     //items is a databoject set, and will therefore be null when cart is empty.
     //TODO: remove item not in cart - insanity check
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:20,代码来源:ShoppingCartTest.php

示例4: clearandlogout

 function clearandlogout()
 {
     $this->cart->clear();
     if ($m = Member::currentUser()) {
         $m->logout();
     }
     Director::redirect("/");
     return false;
 }
开发者ID:nieku,项目名称:silverstripe-ecommerce,代码行数:9,代码来源:ShoppingCart.php

示例5: memberLoggedOut

 function memberLoggedOut()
 {
     if (self::$associate_to_current_order) {
         ShoppingCart::clear();
     }
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:6,代码来源:EcommerceRole.php

示例6: processOrder

    /** 
     * Process the items in the shopping cart from session,
     * creating a new {@link Order} record, and updating the
     * customer's details {@link Member} record.
     * 
     * {@link Payment} instance is created, linked to the order,
     * and payment is processed {@link Payment::processPayment()}
     * 
     * @param array $data Form request data submitted from OrderForm
     * @param Form $form Form object for this action
     * @param HTTPRequest $request Request object for this action
     */
    function processOrder($data, $form, $request)
    {
        $paymentClass = !empty($data['PaymentMethod']) ? $data['PaymentMethod'] : null;
        $payment = class_exists($paymentClass) ? new $paymentClass() : null;
        if (!($payment && $payment instanceof Payment)) {
            user_error(get_class($payment) . ' is not a valid Payment object!', E_USER_ERROR);
        }
        if (!ShoppingCart::has_items()) {
            $form->sessionMessage('Please add some items to your cart', 'bad');
            Director::redirectBack();
            return false;
        }
        // Create new OR update logged in {@link Member} record
        $member = EcommerceRole::createOrMerge($data);
        if (!$member) {
            $form->sessionMessage(_t('OrderForm.MEMBEREXISTS', 'Sorry, a member already exists with that email address.
					If this is your email address, please log in first before placing your order.'), 'bad');
            Director::redirectBack();
            return false;
        }
        $member->write();
        $member->logIn();
        // Create new Order from shopping cart, discard cart contents in session
        $order = ShoppingCart::save_current_order();
        ShoppingCart::clear();
        // Write new record {@link Order} to database
        $form->saveInto($order);
        $order->write();
        // Save payment data from form and process payment
        $form->saveInto($payment);
        $payment->OrderID = $order->ID;
        $payment->Amount = $order->Total();
        $payment->write();
        // Process payment, get the result back
        $result = $payment->processPayment($data, $form);
        // isProcessing(): Long payment process redirected to another website (PayPal, Worldpay)
        if ($result->isProcessing()) {
            return $result->getValue();
        }
        if ($result->isSuccess()) {
            $order->sendReceipt();
        }
        Director::redirect($order->Link());
        return true;
    }
开发者ID:nicolaas,项目名称:silverstripe-ecommerce,代码行数:57,代码来源:OrderForm.php

示例7: testClearEntireCart

 function testClearEntireCart()
 {
     /* Invoke the existing test for adding items to the cart */
     $this->testAddItemsToCart();
     /* Get the items from the cart in session */
     $items = ShoppingCart::get_items();
     /* We have 1 item in the cart */
     $this->assertEquals(count($items), 1, 'There is 1 item in the cart');
     /* Clear the shopping cart */
     ShoppingCart::clear();
     /* Take a peek at what items are in the cart */
     $items = ShoppingCart::get_items();
     /* We have nothing in the cart */
     $this->assertEquals(count($items), 0, 'There are no items in the cart');
     /* Clear the shopping cart */
     ShoppingCart::clear();
 }
开发者ID:nicolaas,项目名称:silverstripe-ecommerce,代码行数:17,代码来源:ShoppingCartTest.php

示例8: ShoppingCart

	<?php 
require 'shoppingCart.class.php';
$cart = new ShoppingCart();
$action = isset($_GET['action']) ? $_GET['action'] : '';
$name = isset($_GET['name']) ? $_GET['name'] : 0;
switch ($action) {
    case 'add':
        foreach ($products as $product) {
            if ($product['name'] == $name) {
                $cart->add($name);
                break;
            }
        }
        break;
    case 'empty':
        $cart->clear();
        break;
    case 'remove':
        $cart->remove($name);
        break;
}
$items = $cart->getItems();
if (!empty($items)) {
    echo '
		<table class="table">
		<tr>
			<td><b>Product</b></td>
			<td><b>Price</b></td>
			<td><b>Qty</b></td>
			<td><b>Total</b></td>
			<td></td>
开发者ID:aaronleslie,项目名称:aaronunix,代码行数:31,代码来源:index.php

示例9: testNoMemberOrder

 function testNoMemberOrder()
 {
     //TODO: test configuration that deines non-member orders
     //adjust configuration to allow non member orders
     OrderForm::set_user_membership_optional(true);
     OrderForm::set_force_membership(false);
     $socks = $this->objFromFixture('Product', 'socks');
     $this->get(ShoppingCart::add_item_link($socks->ID));
     //add a different product
     $cart = ShoppingCart::current_order();
     $this->placeOrder('Donald', 'Duck', 'donald@pondcorp.edu.za', '4 The Strand', null, 'Melbourne', null, 'AU');
     $order = DataObject::get_by_id('Order', $cart->ID);
     $this->assertNotNull($order, 'Order exists');
     if ($order) {
         $this->assertEquals($order->Status, 'Unpaid', 'status is now "unpaid"');
         $this->assertEquals($order->MemberID, 0, 'No associated member');
         $this->assertEquals($order->Total(), 8, 'grand total');
         $this->assertEquals($order->TotalOutstanding(), 8, 'total outstanding');
         $this->assertEquals($order->TotalPaid(), 0, 'total outstanding');
         $this->assertEquals($order->FirstName, 'Donald', 'order first name');
         $this->assertEquals($order->Surname, 'Duck', 'order surname');
         $this->assertEquals($order->Email, 'donald@pondcorp.edu.za', 'order email');
         $this->assertEquals($order->Address, '4 The Strand');
         $this->assertNull($order->AddressLine2, 'order address2');
         $this->assertEquals($order->City, 'Melbourne', 'order city');
         $this->assertNull($order->PostalCode, 'order postcode');
         $this->assertEquals($order->Country, 'AU', 'order country');
     }
     ShoppingCart::clear();
     //cleanup
 }
开发者ID:riddler7,项目名称:silverstripe-ecommerce,代码行数:31,代码来源:OrderTest.php


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