本文整理汇总了PHP中Order::delete_abandoned方法的典型用法代码示例。如果您正苦于以下问题:PHP Order::delete_abandoned方法的具体用法?PHP Order::delete_abandoned怎么用?PHP Order::delete_abandoned使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Order
的用法示例。
在下文中一共展示了Order::delete_abandoned方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testRemoveAbandonedCartsWithProductVariationsTask
/**
* Add a product variation to the cart, change the cart so that it is out of date
* then delete it
*/
function testRemoveAbandonedCartsWithProductVariationsTask()
{
$teeshirtA = $this->objFromFixture('Product', 'teeshirtA');
$this->logInAs('admin');
$teeshirtA->doPublish();
$this->logOut();
$teeshirtAVariation = $this->objFromFixture('Variation', 'teeshirtExtraLargePurpleCotton');
$this->assertEquals('Enabled', $teeshirtAVariation->Status);
$this->assertEquals(5, $teeshirtAVariation->StockLevel()->Level);
//Add variation to the cart
$this->get(Director::makeRelative($teeshirtA->Link()));
$data = array('Quantity' => 1);
foreach ($teeshirtAVariation->Options() as $option) {
$data["Options[{$option->AttributeID}]"] = $option->ID;
}
$this->submitForm('AddToCartForm_AddToCartForm', null, $data);
$teeshirtAVariation = $this->objFromFixture('Variation', 'teeshirtExtraLargePurpleCotton');
$this->assertEquals(4, $teeshirtAVariation->StockLevel()->Level);
$order = CartControllerExtension::get_current_order();
$this->logInAs('admin');
$order->LastActive = '2011-12-22 17:02:49';
$order->Status = 'Cart';
$order->write();
$this->logOut();
Order::delete_abandoned();
DataObject::flush_and_destroy_cache();
$teeshirtAVariation = $this->objFromFixture('Variation', 'teeshirtExtraLargePurpleCotton');
$this->assertEquals(5, $teeshirtAVariation->StockLevel()->Level);
}
示例2: index
/**
* Include some CSS and javascript for the checkout page
*
* TODO why didn't I use init() here?
*
* @return Array Contents for page rendering
*/
function index()
{
//Update stock levels
Order::delete_abandoned();
Requirements::css('swipestripe/css/Shop.css');
Requirements::javascript(THIRDPARTY_DIR . '/jquery/jquery.js');
Requirements::javascript('swipestripe/javascript/CheckoutPage.js');
return array('Content' => $this->Content, 'Form' => $this->Form);
}
示例3: index
/**
* Display a {@link Product}.
*
* @param SS_HTTPRequest $request
*/
function index(SS_HTTPRequest $request)
{
//Update stock levels before displaying product
Order::delete_abandoned();
$product = $this->data();
if ($product && $product->exists()) {
$data = array('Product' => $product, 'Content' => $this->Content, 'Form' => $this->AddToCartForm());
return $this->Customise($data)->renderWith(array('Product', 'Page'));
/*
$ssv = new SSViewer("Page");
$ssv->setTemplateFile("Layout", "Product_show");
return $this->Customise($data)->renderWith($ssv);
*/
} else {
return $this->httpError(404, 'Sorry that product could not be found');
}
}
示例4: process
/**
* Remove {@link Order}s that have not been active for a certain period of time,
* do not have a {@link Payment} attached and have the status of 'Cart'.
*
* @see Order::delete_abandoned()
* @see CliController::process()
*/
function process()
{
date_default_timezone_set('Pacific/Auckland');
Order::delete_abandoned();
}
示例5: testDeleteAbandonedCarts
/**
* Carts abandoned longer than set lifetime are deleted
*/
public function testDeleteAbandonedCarts()
{
$productA = $this->objFromFixture('Product', 'productA');
$shopConfig = $this->objFromFixture('ShopConfig', 'config');
$this->assertEquals(1, $shopConfig->CartTimeout);
$this->assertEquals('hour', $shopConfig->CartTimeoutUnit);
$this->loginAs('admin');
$productA->doPublish();
$this->logOut();
$productALink = $productA->Link();
$this->get(Director::makeRelative($productALink));
$this->submitForm('ProductForm_ProductForm', null, array('Quantity' => 1));
$order = Cart::get_current_order();
$this->assertTrue($order->exists());
Order::delete_abandoned();
DataObject::flush_and_destroy_cache();
$order = Cart::get_current_order();
$this->assertTrue($order->exists());
//Log in as admin, change the shop config and the cart last active and try to delete it
$this->loginAs('admin');
$shopConfig->CartTimeout = 15;
$shopConfig->CartTimeoutUnit = 'minute';
$shopConfig->write();
$date = new DateTime();
$date->sub(new DateInterval('PT20M'));
$order->LastActive = $date->format('Y-m-d H:i:s');
$order->write();
$this->logOut();
Order::delete_abandoned();
DataObject::flush_and_destroy_cache();
$order = Cart::get_current_order();
$this->assertTrue(!$order->exists());
}
示例6: index
/**
* Include some CSS for the cart page.
*
* @return Array Contents for page rendering
*/
function index()
{
//Update stock levels
Order::delete_abandoned();
Requirements::css('swipestripe/css/Shop.css');
return array('Content' => $this->Content, 'Form' => $this->Form);
}