add count

This commit is contained in:
Your Name
2021-08-18 00:30:21 +03:00
parent dfcc5e3558
commit 7cc5655843
2 changed files with 91 additions and 44 deletions

View File

@@ -36,35 +36,17 @@ function checkout_kuri($priceslug, $delivery_id = 1){
if (!isset($price_id['price_id'])) {
echo 'товар не найден';
return false;
}
/** определяем цену товара */
}
# отправляем цену на форму в js
if ($delivery_id == 1){ // тип товара = 1 (только электронная)
$price = $price_id['price']; // электронный прайс
}
else {
if ($price_id['pieces'] > 0 ){
$price = $price_id['offline_price']; // бумажный прайс
$delivery = delivery_list(); // список доставок для бумажной версии
if ($delivery[$delivery_id]['delivery_price'] > 0) {
$price = $price + $delivery[$delivery_id]['delivery_price']; #надбавка за услугу
}
}
else{
echo 'Товара больше нет в наличии';
return;
}
}
/** фиксируем цену в базу */
$add['buy_price'] = $price;
$add['price'] = $price;
else {
$price = $price_id['offline_price']; // бумажный прайс
$delivery = delivery_list(); // список доставок для бумажной версии
}
/** если клиент залогинен */
@@ -93,6 +75,7 @@ function checkout_kuri($priceslug, $delivery_id = 1){
}
# указан ли в поле email
if (isset($_POST['clientmail']) and trim($_POST['clientmail']) !== '') {
@@ -140,6 +123,7 @@ function checkout_kuri($priceslug, $delivery_id = 1){
}
# указано поле адрес
if (isset($_POST['buy_adress']) and trim($_POST['buy_adress']) !== '') {
$add['buy_adress'] = trim($_POST['buy_adress']);
@@ -156,9 +140,43 @@ function checkout_kuri($priceslug, $delivery_id = 1){
$add_order = True;
}
if (isset($_POST['count']))
$count = $_POST['count'];
else
$count = 1;
/** определяем цену товара */
if ($delivery_id == 1){ // тип товара = 1 (только электронная)
$price = $price_id['price']; // электронный прайс
}
else { # физический товар
if ($price_id['pieces'] > 0 ){
$price = $price_id['offline_price']; // бумажный прайс
if ($delivery_id == 2){ #самовывоз
$price = $price * $count;
}
elseif($delivery_id == 2){ #курьером 300рэ
$price = $price * $count;
$price = $price + 300;
}
elseif($delivery_id == 2){ #почта россии за каждый кулек своя доставка
$price = $price + 250;
$price = $price * $count;
}
}else{
echo 'Товара больше нет в наличии';
return;
}
}
}
/** фикстируем клиента в базу */
if (isset($client['client_id'])) {
$add['client_id'] = $client['client_id'];
@@ -181,8 +199,12 @@ function checkout_kuri($priceslug, $delivery_id = 1){
$add['delivery_id'] = $delivery_id;
$add['date_start'] = date('Y-m-d H:i:s');
$add['buy_active'] = 0;
$add['count'] = $count;
/** фиксируем цену в базу */
$add['buy_price'] = $price;
$add['price'] = $price;
$order_id = db_insert('anbuy', $add, 'chitatel'); // добавляем в базу заказ
$order_url = SITE."status/$order_id";