Подсчет цены в корзине

Правила раздела: faq.php?mode=okay
Модератор: Модераторы

Антон
Антон

Сообщение #1 Антон » 29.08.2018, 10:24

Подскажите, пожалуйста, как можно решить данный вопрос. В корзине невозможно поменять количество товара.

Изображение: https://dropmefiles.com/mwxkx

Код

{* The cart page template *}

{* The page title *}
{$meta_title = $lang->cart_title scope=parent}



<section class="agriculture-basket-wrap">
<div class="agriculture-basket">
<h2 class="agriculture-title">
Корзина
</h2>
<!-- /.agriculture-title -->
{foreach $cart->purchases as $purchase}
{$image = $purchase->product->images|first}
<div class="agriculture-basket-item">
<div class="agriculture-basket-item__img">
<img src="{$image->filename|resize:50:50}" alt="{$purchase->product->name|escape}">
</div>
<!-- /.agriculture-basket-item__img -->
<div class="agriculture-basket-item-info">
<div class="agriculture-basket-item-info__title"><a href="{$lang_link}products/{$purchase->product->url}" style="color: black;">{$purchase->product->name|escape}</a></div>
<!-- /.agriculture-basket-item-info__title -->
<!-- <div class="agriculture-basket-item-info__descr">GPS приборы для измерения площади полей</div> -->
<!-- /.agriculture-basket-item-info__descr -->
<div class="agriculture-basket-item-info-options-wrap">
<div class="agriculture-basket-item-info-options">
<div class="agriculture-basket-item-info-options__price">{($purchase->variant->price)|convert} {$currency->sign} {if $purchase->variant->units}/ {$purchase->variant->units|escape}{/if}</div>
<!-- /.agriculture-basket-item-info-options__price -->
<!-- <div class="agriculture-basket-item-info-options__color">Цвет</div> -->
<!-- <img src="http://store.gpsgeometer.com/design/okay_shop_1/images/main/circle-blue.jpg" alt=""> -->
<!-- /.agriculture-basket-item-info-options__colar -->
<!-- <img class="arrow-color" src="http://store.gpsgeometer.com/design/okay_shop_1/images/main/arrow2-down.png" alt=""> -->
<div class="agriculture-basket-item-info-options__sum">Количество</div>
<div class="agriculture-basket-item-info-options__price" id="allprice"></div>
<!-- /.agriculture-basket-item-info-options__sum -->
<img src="http://store.gpsgeometer.com/design/okay_shop_1/images/main/arrow-left.jpg" alt="" onclick="minusOne()">
<span id="number">1</span>
<img src="http://store.gpsgeometer.com/design/okay_shop_1/images/main/arrow-rigth.jpg" alt="" onclick="plusOne()">
<!-- <div class="purchase_amount">
<div class="fn_product_amount{if $settings->is_preorder} fn_is_preorder{/if} amount">
<span class="minus">&minus;</span>
<input class="input_amount" type="text" data-id="{$purchase->variant->id}" name="amounts[{$purchase->variant->id}]" value="{$purchase->amount}" onblur="ajax_change_amount(this, {$purchase->variant->id});" data-max="{$purchase->variant->stock}">
<span class="plus">&plus;</span>
</div>
</div> -->
</div>
<!-- /.agriculture-basket-item-info-options -->
<img src="http://store.gpsgeometer.com/design/okay_shop_1/images/main/icon-close.jpg" alt="icon-close">
</div>
<!-- /.agriculture-basket-item-info-options-wrap -->
</div>
<!-- /.agriculture-basket-item-info -->
</div>
{/foreach}
<!-- /.agriculture-basket-item -->
<div class="agriculture-basket-delivery">
<div class="agriculture-basket-delivery__title">Доставка:</div>
<!-- /.agriculture-basket-delivery__title -->
<input type="radio" class="agriculture-basket-delivery__input">
<label for="" class="agriculture-basket-delivery__label">доставка Новой почтой</label>
<input type="radio" class="agriculture-basket-delivery__input">
<label for="" class="agriculture-basket-delivery__label">самовывоз</label>
</div>
<!-- /.agriculture-basket-delivery -->
<div class="agriculture-basket-total">
<div class="agriculture-basket-total__text">Итоговая стоимость:</div>
<!-- /.agriculture-basket-total__text -->
<div class="agriculture-basket-total__price">{$cart->total_price|convert} {$currency->sign|escape}</div>
<!-- /.agriculture-basket-total__price -->
</div>
<form action="" class="agriculture-basket-form" name="cart">
<div class="agriculture-basket-form__input">
<input type="text" placeholder="ФИО">
<input type="text" placeholder="Номер телефона">
<input type="text" placeholder="Улица">
<input type="text" placeholder="№ дома">
<input type="text" placeholder="№ кв.">
</div>
<!-- /.agriculture-basket-form__input -->
<button class="agriculture-basket-form__btn">
Оформить заказ
</button>
</form>
<!-- /.agriculture-basket-form -->
<!-- /.agriculture-basket-total -->
</div>
<!-- /.agriculture-basket -->
</section>
<!-- /.agriculture-basket-wrap -->
<script>
function plusOne(){
var number = document.getElementById('number').textContent;
number = parseInt(number);
number += 1;
document.getElementById('number').innerHTML = number;

}

function minusOne(){
var number = document.getElementById('number').textContent;
if(number > 1){
number -= 1;
document.getElementById('number').innerHTML = number;
}

}




</script>

korshunov
korshunov
Репутация: 146
Сообщения: 1854
Зарегистрирован: 03.12.2015
С нами: 8 лет 3 месяца
Skype

Сообщение #2 korshunov » 29.08.2018, 11:39

Очень похоже, что Ваш шаблон старый или вообще изначально некачественный. С ходу видны недостатки:
1. JS- скрипты 0 в устаревшем виде, библиотека jquery не используется.
2. В цикле формируется несколько тегов с id="number", в результате чего в функциях plusOne(),minusOne() не будет корректно определяться нужный элемент. Видимо, разработчик вставил в корзину скрипт с карточки товара, где работал только один элемент ввода к-ва,и не потрудился проверить свое произведение.

Лучше всего предъявить претензии разработчику или продавцу шаблона...


Название раздела: Вопросы по работе с OkayCMS
Правила раздела: faq.php?mode=okay

Быстрый ответ


Введите код в точности так, как вы его видите. Регистр символов не имеет значения.
Код подтверждения

   

Вернуться в «Вопросы по работе с OkayCMS»

Кто сейчас на форуме (по активности за 5 минут)

Сейчас этот раздел просматривают: 31 гость