add count
This commit is contained in:
@@ -36,35 +36,17 @@ function checkout_kuri($priceslug, $delivery_id = 1){
|
|||||||
if (!isset($price_id['price_id'])) {
|
if (!isset($price_id['price_id'])) {
|
||||||
echo 'товар не найден';
|
echo 'товар не найден';
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** определяем цену товара */
|
|
||||||
|
|
||||||
|
# отправляем цену на форму в js
|
||||||
if ($delivery_id == 1){ // тип товара = 1 (только электронная)
|
if ($delivery_id == 1){ // тип товара = 1 (только электронная)
|
||||||
$price = $price_id['price']; // электронный прайс
|
$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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
else {
|
||||||
|
$price = $price_id['offline_price']; // бумажный прайс
|
||||||
/** фиксируем цену в базу */
|
$delivery = delivery_list(); // список доставок для бумажной версии
|
||||||
|
}
|
||||||
$add['buy_price'] = $price;
|
|
||||||
$add['price'] = $price;
|
|
||||||
|
|
||||||
|
|
||||||
/** если клиент залогинен */
|
/** если клиент залогинен */
|
||||||
@@ -93,6 +75,7 @@ function checkout_kuri($priceslug, $delivery_id = 1){
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# указан ли в поле email
|
# указан ли в поле email
|
||||||
if (isset($_POST['clientmail']) and trim($_POST['clientmail']) !== '') {
|
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']) !== '') {
|
if (isset($_POST['buy_adress']) and trim($_POST['buy_adress']) !== '') {
|
||||||
$add['buy_adress'] = 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;
|
$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'])) {
|
if (isset($client['client_id'])) {
|
||||||
$add['client_id'] = $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['delivery_id'] = $delivery_id;
|
||||||
$add['date_start'] = date('Y-m-d H:i:s');
|
$add['date_start'] = date('Y-m-d H:i:s');
|
||||||
$add['buy_active'] = 0;
|
$add['buy_active'] = 0;
|
||||||
|
$add['count'] = $count;
|
||||||
|
|
||||||
|
/** фиксируем цену в базу */
|
||||||
|
$add['buy_price'] = $price;
|
||||||
|
$add['price'] = $price;
|
||||||
|
|
||||||
$order_id = db_insert('anbuy', $add, 'chitatel'); // добавляем в базу заказ
|
$order_id = db_insert('anbuy', $add, 'chitatel'); // добавляем в базу заказ
|
||||||
$order_url = SITE."status/$order_id";
|
$order_url = SITE."status/$order_id";
|
||||||
|
|
||||||
|
|||||||
@@ -2,41 +2,57 @@
|
|||||||
<script>
|
<script>
|
||||||
|
|
||||||
var product_price = <?=$price_id['offline_price']?>;
|
var product_price = <?=$price_id['offline_price']?>;
|
||||||
|
|
||||||
|
|
||||||
function devilery_check(myRadio){
|
function itog(){
|
||||||
|
|
||||||
var itog = product_price;
|
var itog = product_price;
|
||||||
var itog_el = document.getElementById("span_itog");
|
var itog_el = document.getElementById("span_itog");
|
||||||
|
var count = document.getElementById('count').value;
|
||||||
|
|
||||||
|
|
||||||
|
if (document.getElementById('devilery_id1').checked) {
|
||||||
|
itog = product_price * count;
|
||||||
|
}
|
||||||
|
else if (document.getElementById('devilery_id2').checked){
|
||||||
|
itog = product_price * count;
|
||||||
|
itog = itog + 300;
|
||||||
|
}
|
||||||
|
else if (document.getElementById('devilery_id3').checked){
|
||||||
|
itog = product_price + 250;
|
||||||
|
itog = itog * count;
|
||||||
|
}
|
||||||
|
|
||||||
|
itog_el.innerHTML = itog + ' руб.';
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function devilery_check(){
|
||||||
|
|
||||||
|
itog();
|
||||||
|
|
||||||
var el_adress = document.getElementById("buy_adress");
|
var el_adress = document.getElementById("buy_adress");
|
||||||
|
|
||||||
if (myRadio.value == 2){
|
if (document.getElementById('devilery_id1').checked){
|
||||||
itog = product_price;
|
|
||||||
document.getElementById("form_adress").style.display='none';
|
document.getElementById("form_adress").style.display='none';
|
||||||
document.getElementById("form_samo").style.display='block';
|
document.getElementById("form_samo").style.display='block';
|
||||||
}
|
}
|
||||||
else if(myRadio.value == 3){
|
else if(document.getElementById('devilery_id2').checked){
|
||||||
itog = product_price + 300;
|
|
||||||
document.getElementById("form_adress").style.display='block';
|
document.getElementById("form_adress").style.display='block';
|
||||||
document.getElementById("form_samo").style.display='none';
|
document.getElementById("form_samo").style.display='none';
|
||||||
el_adress.placeholder='Адрес в свободной форме';
|
el_adress.placeholder='Адрес в свободной форме';
|
||||||
|
|
||||||
}
|
}
|
||||||
else if(myRadio.value == 4){
|
else if(document.getElementById('devilery_id3').checked){
|
||||||
itog = product_price + 250;
|
|
||||||
document.getElementById("form_adress").style.display='block';
|
document.getElementById("form_adress").style.display='block';
|
||||||
document.getElementById("form_samo").style.display='none';
|
document.getElementById("form_samo").style.display='none';
|
||||||
el_adress.placeholder='Индекс (обязательно). Далее область, населенный пункт и Ваш адрес';
|
el_adress.placeholder='Индекс (обязательно). Далее область, населенный пункт и Ваш адрес';
|
||||||
}
|
}
|
||||||
|
|
||||||
itog_el.innerHTML = itog + ' руб.';
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<form id="clientform" class="clientform" action="<?=$submit_link?>" method="POST">
|
<form id="clientform" class="clientform" action="<?=$submit_link?>" method="POST">
|
||||||
@@ -64,14 +80,14 @@
|
|||||||
<p style="font-weight: bold;font-size: 22px;"><label for="buy_tel">Телефон для связи*:</label></p>
|
<p style="font-weight: bold;font-size: 22px;"><label for="buy_tel">Телефон для связи*:</label></p>
|
||||||
<p><em>*Для подтверждения заказа</em></p>
|
<p><em>*Для подтверждения заказа</em></p>
|
||||||
|
|
||||||
<p><input id="buy_tel" name="buy_tel" value="<?=post_value("buy_tel")?>" type="text"></textarea></p>
|
<p><input id="buy_tel" name="buy_tel" value="<?=post_value("buy_tel")?>" type="tel" pattern="[0-9]{3}-[0-9]{3}-[0-9]{4}"></textarea></p>
|
||||||
|
|
||||||
<p style="font-weight: bold;font-size: 22px;"><label for="devilery_id">Доставка:</label></p>
|
<p style="font-weight: bold;font-size: 22px;"><label for="devilery_id">Доставка:</label></p>
|
||||||
|
|
||||||
<?foreach($delivery as $ditem):?>
|
<?foreach($delivery as $ditem):?>
|
||||||
<?$dd++;
|
<?$dd++;
|
||||||
$checked = ($ditem['delivery_id'] == $delivery_id) ? ' checked': '';?>
|
$checked = ($ditem['delivery_id'] == $delivery_id) ? ' checked': '';?>
|
||||||
<p><input name="delivery_id" type="radio" id="devilery_id<?=$dd?>" onclick="devilery_check(this);" value="<?=$ditem['delivery_id']?>"<?=$checked?>>
|
<p><input name="delivery_id" type="radio" id="devilery_id<?=$dd?>" onclick="devilery_check();" value="<?=$ditem['delivery_id']?>"<?=$checked?>>
|
||||||
<?=$ditem['delivery']?>
|
<?=$ditem['delivery']?>
|
||||||
<?if ($ditem['delivery_price'] > 0):?>
|
<?if ($ditem['delivery_price'] > 0):?>
|
||||||
+ <?=$ditem['delivery_price']?> руб.
|
+ <?=$ditem['delivery_price']?> руб.
|
||||||
@@ -82,6 +98,7 @@
|
|||||||
<div id="form_samo" class="adress_box" style="display: <?= ($delivery_id == 2) ? 'block' : 'none' ?>;">
|
<div id="form_samo" class="adress_box" style="display: <?= ($delivery_id == 2) ? 'block' : 'none' ?>;">
|
||||||
<p>Москва, метро "Аэропорт", Авиационный переулок, д. 4А (здание МФЮА), к. 104</p>
|
<p>Москва, метро "Аэропорт", Авиационный переулок, д. 4А (здание МФЮА), к. 104</p>
|
||||||
<p>Мы работаем пн.-пт. c 10:00 - 18:00</p>
|
<p>Мы работаем пн.-пт. c 10:00 - 18:00</p>
|
||||||
|
<p><strong><em>Резерв - 3 рабочих дня<em></strong></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div id="form_adress" class="adress_box" style="display: <?= ($delivery_id == 3 or $delivery_id == 4) ? 'block' : 'none' ?>;">
|
<div id="form_adress" class="adress_box" style="display: <?= ($delivery_id == 3 or $delivery_id == 4) ? 'block' : 'none' ?>;">
|
||||||
@@ -90,9 +107,13 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div>
|
<div>
|
||||||
<p>Телефоны для консультаций: <strong>8(495)980-45-60</strong>, <strong><a href="tel:+79686365180">8(958)636-51-80</a></strong></p>
|
<p>Телефоны для консультаций: <strong><a href="tel:+74959804560">8(495)980-45-60</a></strong>, <strong><a href="tel:+79686365180">8(958)636-51-80</a></strong></p>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div>
|
||||||
|
<p><input name="count" id="count" type="number" value="<?=post_value("count")?>" min="1" max="999" onclick="itog();"> штук</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
<div id="form_pay">
|
<div id="form_pay">
|
||||||
<p style="font-weight: bold;font-size: 22px;"><label for="buy_adress">Оплата:</label></p>
|
<p style="font-weight: bold;font-size: 22px;"><label for="buy_adress">Оплата:</label></p>
|
||||||
|
|
||||||
@@ -115,7 +136,11 @@
|
|||||||
<p><label>Нажимая кнопку «Купить», я соглашаюсь <a href="https://argumenti.ru/subscribe_condition">с условиями получения услуги</a></label></p>
|
<p><label>Нажимая кнопку «Купить», я соглашаюсь <a href="https://argumenti.ru/subscribe_condition">с условиями получения услуги</a></label></p>
|
||||||
<p><input style="background: #555555;color: white;width: 30%;cursor: pointer;padding: 0;font-weight: 700;font-size: 15px;border-radius: 3px;border: 0;line-height: 0;display: block;outline: none;height: 35px;" type="submit" id="submit" value="Купить"></p>
|
<p><input style="background: #555555;color: white;width: 30%;cursor: pointer;padding: 0;font-weight: 700;font-size: 15px;border-radius: 3px;border: 0;line-height: 0;display: block;outline: none;height: 35px;" type="submit" id="submit" value="Купить"></p>
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
itog();
|
||||||
|
</script>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user