prestashop 1.6通过javascript从tpl产品列表中获取值

prestashop 1.6通过javascript从tpl产品列表中获取值,javascript,jquery,task-parallel-library,prestashop,smarty,Javascript,Jquery,Task Parallel Library,Prestashop,Smarty,我正在使用prestashop 1.6,我正在努力实现以下目标: -在产品列表中,我创建了一个添加数量按钮 <!------------------------ quantity wanted ----------------------------------------------> {if !$PS_CATALOG_MODE} <p class="quantity_wanted_p_"{if (!$allow_oosp &&

我正在使用prestashop 1.6,我正在努力实现以下目标: -在产品列表中,我创建了一个添加数量按钮

<!------------------------ quantity wanted ---------------------------------------------->
        {if !$PS_CATALOG_MODE}
        <p class="quantity_wanted_p_"{if (!$allow_oosp && $product->quantity <= 0) || !$product->available_for_order || $PS_CATALOG_MODE} style="display: block;"{/if}>
        <!-- <label>{l s='Quantity'}</label> -->
            <a class="btn button-minus product_quantity_down decrement_qty" data-field-qty="{$product.minimal_quantity}">
                <span><i class="icon-minus"></i></span>
            </a>
            <input type="number" min="1" name="qty" id="quantity_wanted_{$product.id_product|intval}" class="text inputqtyfield" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product.minimal_quantity > 1}{$product.minimal_quantity}{else}1{/if}{/if}" />
            <span class="minQty" style="display:none;">{$product.minimal_quantity}</span>
            <a class="btn button-plus product_quantity_up increment_qty">
                <span><i class="icon-plus"></i></span>
            </a>
            <span class="clearfix"></span>
        </p>
        {/if}
$(文档).ready(函数(){ $('.increment_qty')。单击(函数(){ var oldVal=$(this.parent().find(“input”).val(); if(parseFloat(oldVal)>=0){ var newVal=parseFloat(oldVal)+1; $(this.parent().find(“input”).val(newVal); }
}))

}))

  • 所有这些都很好,但现在我想用最小数量来增加或减少,而不是1,因此,如果客户点击+按钮时产品有10个最小购买量,结果是20个,再点击30个,依此类推……但我无法在这个文件global.js中获得最小数量,有任何想法如何实现吗?

  • /////quantities in  default product list
    
    $('.decrement_qty').click(function() {
      var oldVal = jQuery(this).parent().find("input").val();
      if ( parseFloat(oldVal) >= 1 ) {
        var newVal = parseFloat(oldVal) - 1;
        $(this).parent().find("input").val(newVal);
      }
    });