Изменение цены при изменении количества товара в Дефолте presta 1.6.1
По умолчанию не меняется цена! Как сделать чтобы при изменении количества сразу же менялась цена?
Проверено на 1.6.1.17
product.js находим и заменяем строки 
359-362
Код:
if (!isNaN(currentVal) && currentVal < quantityAvailableT)
        $('input[name='+fieldName+']').val(currentVal + 1).trigger('keyup');
    else
        $('input[name='+fieldName+']').val(quantityAvailableT);
меняем на
Код:
if (!isNaN(currentVal) && currentVal < quantityAvailableT) {
    $("input[name=" + fieldName + "]").val(currentVal + 1).trigger("keyup");
    var total = (total = productPrice * (currentVal + 1)).toFixed(2);
    $("p.our_price_display").fadeOut(), $("span#our_price_display").text(total + " " + currencySign), $("p.our_price_display").fadeIn()
} else $("input[name=" + fieldName + "]").val(quantityAvailableT);
назодим строки 371-374
Код:
if (!isNaN(currentVal) && currentVal > 1)
        $('input[name='+fieldName+']').val(currentVal - 1).trigger('keyup');
    else
        $('input[name='+fieldName+']').val(1);
меняем на
Код:
if (!isNaN(currentVal) && currentVal > 1) {
    $("input[name=" + fieldName + "]").val(currentVal - 1).trigger("keyup");
    var total = (total = productPrice * (currentVal - 1)).toFixed(2);
    $("p.our_price_display").fadeOut(), $("span#our_price_display").text(total - " " + currencySign), $("p.our_price_display").fadeIn()
} else $("input[name=" + fieldName + "]").val(1);
открываем product.tpl 
находим строки 320 - 330
Код:
<p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
                            <label for="quantity_wanted">{l s='Quantity'}</label>
                            <input type="number" min="1" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}" />
                            <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down">
                                <span><i class="icon-minus"></i></span>
                            </a>
                            <a href="#" data-field-qty="qty" class="btn btn-default button-plus product_quantity_up">
                                <span><i class="icon-plus"></i></span>
                            </a>
                            <span class="clearfix"></span>
                        </p>
меняем на
Код:
<p id="quantity_wanted_p"{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
                 {literal}
                 <script type="text/javascript">
                $(document).ready(function() {
                    $("#quantity_wanted").val(1), $(".qty_up i").on("click", function() {
                        isNaN(parseInt($("#quantity_wanted").val())) ? $("#quantity_wanted").val(1) : ($("#quantity_wanted").val(parseInt($("#quantity_wanted").val()) + 1), $("#our_price_display").html(((productPrice * $("#quantity_wanted").val()).toFixed(2) + " " + currencySign).replace(".", ",")))
                    }), $(".qty_down i").on("click", function() {
                        isNaN(parseInt($("#quantity_wanted").val())) ? $("#quantity_wanted").val(1) : parseInt($("#quantity_wanted").val()) <= 1 || ($("#quantity_wanted").val(parseInt($("#quantity_wanted").val()) - 1), $("#our_price_display").html(((productPrice * $("#quantity_wanted").val()).toFixed(2) + " " + currencySign).replace(".", ",")))
                    })
                });
                 </script>
                 {/literal}
                 <label>{l s='Quantity:'}</label>
                 <span class="qty_down floatleft"><i class="icon-minus"></i></span>
                 <input type="text" name="qty" id="quantity_wanted" class="text" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 1}{$product->minimal_quantity}{else}1{/if}{/if}" size="2" maxlength="3" {if $product->minimal_quantity > 1}onkeyup="checkMinimalQuantity({$product->minimal_quantity});"{/if} />
                 <span class="qty_up floatleft"><i class="icon-plus"></i></span>
                </p>
ну и на сладкое добавляем в файл product.css стили кнопок плюс и минус
Код:
span.qty_down, span.qty_up{
    display: inline-block;
    border: 1px solid #ddd;
    width: 25px;
    height: 26px;
    text-align: center;
    vertical-align: middle;
    padding: 2px 0 0 0;
    background: white;
    background-image: -webkit-gradient(linear, left 0%, left 100%, from(white), to(#fbfbfb));
    background-image: -webkit-linear-gradient(top, white, 0%, #fbfbfb, 100%);
    background-image: -moz-linear-gradient(top, white 0%, #fbfbfb 100%);
    background-image: linear-gradient(to bottom, #ffffff 0%, #fbfbfb 100%);
    background-repeat: repeat-x;
    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFFFF', endColorstr='#FFFBFBFB', GradientType=0);
cursor:pointer;margin-right: -4px;margin-left: 1px;}
span.qty_down:hover, span.qty_up:hover {color: #333;}
span.qty_down:hover, span.qty_up:hover{filter: none;background: #f6f6f6;}
Сообщение отредактировал Triton63 (16-09-2017 21:04)