本文整理匯總了PHP中OrderDetail::addQuantity方法的典型用法代碼示例。如果您正苦於以下問題:PHP OrderDetail::addQuantity方法的具體用法?PHP OrderDetail::addQuantity怎麽用?PHP OrderDetail::addQuantity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類OrderDetail
的用法示例。
在下文中一共展示了OrderDetail::addQuantity方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: create
public function create()
{
if (!isset($_POST['quantity']) || !isset($_POST['product_id']) || !isset($_POST['product_price'])) {
return call('pages', 'error');
}
if (isAdmin()) {
$_SESSION['alert'] = "Admin is not able to buy products";
return header("Location: index.php?controller=products&action=index");
}
if (!isset($_SESSION['id'])) {
$_SESSION['alert'] = "Please log in before shopping";
return header("Location: index.php?controller=products&action=index");
}
if (!Order::isValid($_SESSION['id'])) {
$_SESSION['alert'] = "Before you can buy products, you must provide necessary perfonal information";
return header("Location: index.php?controller=products&action=index");
}
if (!isset($_SESSION['orderID'])) {
$_SESSION['orderID'] = Order::create($_SESSION['id']);
}
require_once 'models/order_detail.php';
if (OrderDetail::check($_SESSION['orderID'], $_POST['product_id'])) {
OrderDetail::addQuantity($_SESSION['orderID'], $_POST['product_id'], $_POST['quantity']);
} else {
OrderDetail::create($_SESSION['orderID'], $_POST['product_id'], $_POST['product_price'], $_POST['quantity']);
}
$_SESSION['notice'] = "Added product to basket";
header("Location: index.php?controller=products&action=index");
}