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


PHP ShoppingCart::get_items方法代码示例

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


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

示例1: 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

示例2: 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

示例3: Items

 /**
  * Returns the items of the order, if it hasn't been saved yet
  * it returns the items from session, if it has, it returns them 
  * from the DB entry.
  */
 function Items()
 {
     if ($this->ID) {
         return $this->itemsFromDatabase();
     } elseif ($items = ShoppingCart::get_items()) {
         return $this->createItems($items);
     }
 }
开发者ID:nicolaas,项目名称:silverstripe-ecommerce,代码行数:13,代码来源:Order.php


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