本文整理匯總了PHP中ShoppingCart::add_new_item方法的典型用法代碼示例。如果您正苦於以下問題:PHP ShoppingCart::add_new_item方法的具體用法?PHP ShoppingCart::add_new_item怎麽用?PHP ShoppingCart::add_new_item使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類ShoppingCart
的用法示例。
在下文中一共展示了ShoppingCart::add_new_item方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: addVariation
function addVariation()
{
if ($this->AllowPurchase && $this->urlParams['ID']) {
$variation = DataObject::get_one('ProductVariation', sprintf("`ID` = %d AND `ProductID` = %d", (int) $this->urlParams['ID'], (int) $this->ID));
if ($variation) {
if ($variation->AllowPurchase()) {
ShoppingCart::add_new_item(new ProductVariation_OrderItem($variation));
if (!$this->isAjax()) {
Director::redirectBack();
}
}
}
}
}
示例2: additem
/**
* Either increments the count or creates a new item.
*/
function additem($request)
{
if ($itemId = $request->param('ID') && ($product = $this->buyableFromURL())) {
if ($item = ShoppingCart::get_item($this->urlFilter())) {
ShoppingCart::add_item($item);
return self::return_data("success", "Extra item added");
//TODO: i18n
} else {
if ($orderitem = $this->create_order_item($product, 1, self::get_clean_param_array($this->getRequest()->getVars()))) {
ShoppingCart::add_new_item($orderitem);
return self::return_data("success", "Item added");
//TODO: i18n
}
}
}
return self::return_data("failure", "Item could not be added");
//TODO: i18n
}