本文整理汇总了PHP中Basket::getTotalPrice方法的典型用法代码示例。如果您正苦于以下问题:PHP Basket::getTotalPrice方法的具体用法?PHP Basket::getTotalPrice怎么用?PHP Basket::getTotalPrice使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Basket
的用法示例。
在下文中一共展示了Basket::getTotalPrice方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: actionView
public function actionView($id)
{
self::validateAdmin();
$order = Order::getOrderById($id);
$productQuantity = json_decode($order['products'], true);
$productId = array_keys($productQuantity);
$products = Products::getProductlistById($productId);
$totalPrice = Basket::getTotalPrice($products, $productQuantity);
$total = array_sum($totalPrice);
require_once ROOT . '/views/admin_order/view.php';
return true;
}
示例2: actionOrder
public function actionOrder()
{
$platform = array();
$errors = array();
$userName = '';
$userEmail = '';
$userPhone = '';
$userComment = '';
$platform = Platform::getPlatformList();
$result = false;
if (isset($_POST['submit'])) {
$userName = $_POST['name'];
$userEmail = $_POST['email'];
$userPhone = $_POST['phone'];
$userComment = $_POST['message'];
$errors = false;
if (!User::validateUsername($userName)) {
$errors[] = "Неверное имя";
}
if (!User::validateEmail($userEmail)) {
$errors[] = "Неверный Email";
}
if (!User::validatePhone($userPhone)) {
$errors[] = "Неккоректный телефон";
}
if ($errors == false) {
$productsBasket = Basket::getProducts();
if (User::isGuest()) {
$userId = false;
} else {
$userId = User::validateLogged();
}
$result = Order::save($userName, $userEmail, $userPhone, $userComment, $userId, $productsBasket);
if ($result) {
$adminEmail = "alexey.vnu@gmail.com";
$subject = "Новый заказ";
mail($adminEmail, $subject, $userComment);
Basket::clear();
}
} else {
$productsInBasket = Basket::getProducts();
$productId = array_keys($productsInBasket);
$products = Products::getProductsByIdInBasket($productId);
$totalPrice = Basket::getTotalPrice($products);
$total = array_sum($totalPrice);
$totalQuantity = Basket::countItem();
}
} else {
$productsInbasket = Basket::getProducts();
if ($productsInbasket == false) {
header("Loaction: /");
} else {
$productId = array_keys($productsInbasket);
$products = Products::getProductsByIdInBasket($productId);
$totalPrice = Basket::getTotalPrice($products);
$totalQuantity = Basket::countItem();
$userName = false;
$userEmail = false;
$userPhone = false;
$userComment = false;
if (User::isGuest()) {
} else {
$userId = User::validateLogged();
$user = User::getUserById($userId);
$userName = $user['name'];
$userEmail = $user['email'];
}
}
}
require_once ROOT . "/views/basket/order.php";
return true;
}
示例3: actSaveOrder
function actSaveOrder()
{
include 'modules/catalog/Basket.class.php';
global $ST, $post;
$id = $post->getInt('id');
$count = $post->getArray('count');
$price = $post->getArray('price');
if (!$count) {
echo printJSON(array('msg' => 'Ошибка сохранения. Корзина пуста'));
exit;
}
$orderItem = $count;
$rs = $ST->select("SELECT * \r\n\t\t\tFROM sc_shop_item \r\n\t\t\tWHERE id IN (" . implode(',', array_keys($count)) . ")");
while ($rs->next()) {
$orderItem[$rs->get('id')] = array('count' => $count[$rs->get('id')], 'price' => $price[$rs->get('id')]);
}
$basket = new Basket($orderItem);
$basket->delivery = $post->getFloat('delivery');
$basket->discount = $post->getFloat('discount');
$data = array('order_status' => $post->get('order_status'), 'comment' => $post->get('comment'), 'review' => $post->get('review'), 'perfid' => $this->getUserId(), 'price' => $basket->getPrice(), 'total_price' => $basket->getTotalPrice(), 'discount' => $basket->discount, 'delivery' => $basket->delivery, 'delivery_type' => $post->get('delivery_type'), 'date' => dte($post->get('date'), 'Y-m-d'), 'time' => $post->get('time'), 'fullname' => $post->get('fullname'), 'address' => $post->get('address'), 'phone' => $post->get('phone'), 'additionally' => $post->get('additionally'));
$out['msg'] = 'Сохранено';
if ($id) {
if (in_array($data['order_status'], array(3))) {
//Логируем изменения
$cur_data = array('date' => '', 'discount' => '', 'delivery' => '', 'delivery_type' => '');
$cur_data_item = array();
$rs = $ST->select("SELECT " . implode(',', array_keys($cur_data)) . " FROM sc_shop_order WHERE id={$id}");
if ($rs->next()) {
$cur_data = $rs->getRow();
$rs = $ST->select("SELECT itemid,count,price FROM sc_shop_order_item WHERE orderid={$id} ORDER BY itemid");
while ($rs->next()) {
$row = $rs->getRow();
$cur_data['items'][$rs->get('itemid')] = array('count' => $rs->get('count'), 'price' => $rs->get('price'));
}
}
// $change=array();
// foreach ($cur_data as $k=>$v){
// if(trim($v)!=trim($data[$k])){
// $change[$k]=$data[$k];
// }
// }
// ksort($orderItem);
// if(json_encode($cur_data_item)!=json_encode($orderItem)){
// $change['item']=$cur_data_item;
// }
if ($cur_data) {
$ST->insert('sc_shop_order_datalog', array('orderid' => $id, 'data' => serialize($cur_data)));
}
}
////////////////////////////////////
$ST->update('sc_shop_order', $data, "id=" . $id);
$ST->delete('sc_shop_order_item', 'orderid=' . $id);
} else {
$data['userid'] = $this->getUserId();
$id = $ST->insert('sc_shop_order', $data);
}
$this->logOrder($id, $this->getUserId(), $post->get('order_status'));
foreach ($orderItem as $key => $row) {
$d['orderid'] = $id;
$d['itemid'] = $key;
$d['count'] = $row['count'];
$d['price'] = $row['price'];
$ST->insert('sc_shop_order_item', $d);
}
$out['id'] = $id;
echo printJSON($out);
exit;
}
示例4: checkOrder
function checkOrder($args, $basket)
{
$error = array();
// if(!trim($args->get('fullname' ))){$error['fullname']="Введите ФИО!";}
if (!trim($args->get('phone'))) {
$error['phone'] = 'Введите телефон';
}
$error += $this->checkDelivery($args);
// if($err=$this->checkMail($args->get('mail'),false))$error['mail']=$err;
// if($args->getInt('reg')==1 && !$args->exists('auto_pass')){//Хочет реги и не автопароль
// if(strlen($args->get('reg_password'))<6){
// $error['reg_password']='длина пароля не должна быть меньше 6 символов';
// }elseif($args->get('reg_password')!==$args->get('cpassword')){
// $error['reg_password']='пароль и подтверждение не совпадают';
// }
// }
// if($basket['delivery']!==false){
// if(!$args->get('pay_system')){
// $error['pay_system']='Выберите способ оплаты';
// }
// }
if (empty($basket['basket'])) {
$error['basket'] = 'Корзина пуста';
}
$bsk = new Basket($this->getBasket());
if ($bsk->getTotalPrice() < (int) $this->cfg('SHOP_ORDER_COND')) {
$error['basket'] = "Сумма заказа не менее {$this->cfg('SHOP_ORDER_COND')} р.";
} else {
foreach ($this->getBasket() as $item) {
if ($item['in_stock'] < 0) {
$error['basket'] = $item['name'] . " НЕТ В НАЛИЧИИ";
break;
}
}
}
return $error;
}