Jump to content

How to increment product quantity of 10 units


Recommended Posts

Hi all,

I need, only for some products of a shop (based on the category), that the step increment of the wanted quantity is 10 units and not 1.

That is, if i click the "+" button then the quantity of the product in the cart should increment of 10 units.

Is it configurable with Prestashop 1.6 or I have to change the code ?

In the second case which files should I modify?

 

Thank you very much

 

Claudio

Edited by ilclaudio (see edit history)
Link to comment
Share on other sites

You need to change the code. However, since you need it on certain products only, it's not going to be that easy.
You need to edit product.tpl, this field

 

<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}" />

Use step="10"

However, this will apply to all products. You can try with $Product->id_category_default and check if it's the one you want. If not, display the standard

  • Like 1
Link to comment
Share on other sites

Thank you Nemo and electriz.

 

In the meantime I've done in this way:

 

1) I've modified the file product.tpl:

 

{assign cat3 [['id_category' => 3]]}
{if Product::idIsOnCategoryId($smarty.get.id_product, $cat3)}
                                                                                <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_10">
{else}
                                                                                <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down">
{/if}

 

2) Then I've added these lines to js/product.js:

 

// The button to increment the product value
$(document).on('click', '.product_quantity_up_10', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name=+fieldName+]').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name=+fieldName+]').val(currentVal + 10).trigger('keyup');
        else
                $('input[name=+fieldName+]').val(quantityAvailableT);
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_10', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name=+fieldName+]').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 10)
                $('input[name=+fieldName+]').val(currentVal - 10).trigger('keyup');
        else
                $('input[name=+fieldName+]').val(10);
});
 

I konw, It is hard-coded, but it works for me.

I think however that the "step quantity" of a product should be a standard feature of the ecommerce.

 

Claudio

Edited by ilclaudio (see edit history)
  • Like 1
Link to comment
Share on other sites

  • 4 months later...

Hello Claudio !

 

I tried your solution but it doesn't work for me ...

 

Where did you have add your code for product.tpl ? 

 

Just below it :

{if !$PS_CATALOG_MODE}
						<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>
						{/if}

Maybe I had to put it in a conditon ?

 

I have also modify it :

 

 

<a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_10">
{else}
<a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down">

I change to : 

 <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_10">
{else}

<a href="#" data-field-qty="qty" class="btn btn-default button-plus product_quantity_up_10">

 

Then, where did you had the code for product.js ?

Also just below the other one without specific quantity ?

 

 

Many thanks

Link to comment
Share on other sites

I had increase by 10 the quantity only for the products of a fixed category, this is why I have duplicated the link that increases the quantity.

After that I have added the javascript code to related to the classes "product_quantity_down_10" and "product_quantity_up_10".

 

You have to be sure that the new javascript is loaded when you try this functionality.

 

cld

Link to comment
Share on other sites

Hey claudio,

 

Thanks !

 

I understand the process ;)

 

But where did you add this part of code in product.tpl ?

Did you remove the other one ?

 

 

For product.js I added the code just below the other one for 1 quantity incrementation. (with the right called class)

Link to comment
Share on other sites

Yes it is true, but I've disabled in the checkout the possibility of changing the quantities. You can only use the buttons to increase and decrease quantities.

However you're right, but I had to solve the problem and this works.

I think it should be a configurable parameter of Prestashop, but this feature it is not present in this moment.

 

cld

Link to comment
Share on other sites

Hello,

 

Thanks for your help !

 

I succeed yesterday adding this part of code :

{assign cat37 [['id_category' => 37]]}
						{if Product::idIsOnCategoryId($smarty.get.id_product, $cat37)}
						<label for="quantity_wanted">{l s='Quantity'}</label>
						<input type="text" min="10" name="qty" id="quantity_wanted" class="text" disabled="disabled" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 10}{$product->minimal_quantity}{else}10{/if}{/if}" />
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_10">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_10">
                         	<span><i class="icon-plus"></i></span>
							</a>
						{/if}

						{else}
						<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>

I let in place the original code for any quantity but I add a condition before !

 

Then I add to product.js the code you wrote ;) :

$(document).on('click', '.product_quantity_up_10', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 10).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_10', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 10)
                $('input[name='+fieldName+']').val(currentVal - 10).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(10);

        $('#quantity_wanted').change();    
});

All was good but when a product doesn't belong to a specific category (for specific incrementation), the "else" code doesn't worked ... :

 

 http://hpics.li/54f8930

 

Can you help me for that ? what's wrong ?

I delete my code and add the original product.tpl .... but still doesn't work (also clear cache...)

Link to comment
Share on other sites

  • 3 weeks later...

Hello,

 

Just to let you know (if it can help someone)

Here is my solution (can be improve of course) :

 

 

Product.tpl :

Just after <div class="product_attributes clearfix">

  1. First, I declare my variables
  2. Then "if" condition with differents increments per 10, 20, 25, 50 (as you want)
  3. And finally the "else" for just an increment of one
{if !$PS_CATALOG_MODE}

 
						{assign cat37 [['id_category' => 37]]}
						{assign cat38 [['id_category' => 38]]}
						{assign cat39 [['id_category' => 39]]}
						{assign cat40 [['id_category' => 40]]}
						{assign cat41 [['id_category' => 41]]}


						{if Product::idIsOnCategoryId($smarty.get.id_product, $cat37)}
						<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="text" min="10" name="qty" id="quantity_wanted" class="text" disabled="disabled" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 10}{$product->minimal_quantity}{else}10{/if}{/if}" />
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_10">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_10">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>
											

						
						{elseif Product::idIsOnCategoryId($smarty.get.id_product, $cat38)}
						<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="text" min="20" name="qty" id="quantity_wanted" class="text" disabled="disabled" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 20}{$product->minimal_quantity}{else}20{/if}{/if}"  />
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_20">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_20">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>

					
						
						{elseif Product::idIsOnCategoryId($smarty.get.id_product, $cat39)}
						<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="text" min="25" name="qty" id="quantity_wanted" class="text" disabled="disabled" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 25}{$product->minimal_quantity}{else}25{/if}{/if}"/>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_25">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_25">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>
														

						
						{elseif Product::idIsOnCategoryId($smarty.get.id_product, $cat41)}
						<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="text" min="6" name="qty" id="quantity_wanted" class="text" disabled="disabled" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 6}{$product->minimal_quantity}{else}6{/if}{/if}" />
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_6">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_6">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>
						

						
						{elseif Product::idIsOnCategoryId($smarty.get.id_product, $cat40)}
						<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="text" min="50" name="qty" id="quantity_wanted" class="text" disabled="disabled" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 50}{$product->minimal_quantity}{else}50{/if}{/if}"  />
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_50">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_50">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>

						

						

						{else}
						<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" disabled="disabled" 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>	


						{/if}
						{/if}

Product.js :

Just under the comment : // The button to increment the product value

You already have the script for 1 quantity and then you duplicate for 10, 20, 25, 50 (as you want)

$(document).on('click', '.product_quantity_up_10', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 10).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_10', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 10)
                $('input[name='+fieldName+']').val(currentVal - 10).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(10);

        $('#quantity_wanted').change();    
});



$(document).on('click', '.product_quantity_up_20', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 20).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_20', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 20)
                $('input[name='+fieldName+']').val(currentVal - 20).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(20);

        $('#quantity_wanted').change();    
});


$(document).on('click', '.product_quantity_up_25', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 25).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_25', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 25)
                $('input[name='+fieldName+']').val(currentVal - 25).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(25);

        $('#quantity_wanted').change();    
});

$(document).on('click', '.product_quantity_up_50', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 50).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_50', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 50)
                $('input[name='+fieldName+']').val(currentVal - 50).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(50);

        $('#quantity_wanted').change();    
});

$(document).on('click', '.product_quantity_up_6', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 6).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_6', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 6)
                $('input[name='+fieldName+']').val(currentVal - 6).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(6);

        $('#quantity_wanted').change();    
});
Link to comment
Share on other sites

  • 1 year later...
On 1/18/2017 at 2:36 PM, Embalim said:

You already have the script for 1 quantity and then you duplicate for 10, 20, 25, 50 (as you want)

thx man, that was awesome

how can i do it for 0.5

i'm using prestashop 1.6.1.18

i tried this but it didn't work

 

product.tpl

<div class="product_attributes clearfix">
						<!-- quantity wanted -->
						{if !$PS_CATALOG_MODE}

						{assign cat16 [['id_category' => 16]]}
						{assign cat17 [['id_category' => 17]]}
						
						{if Product::idIsOnCategoryId($smarty.get.id_product, $cat16)}
						<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="text" min="1" name="qty" id="quantity_wanted" class="text" disabled="disabled" 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_1">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_1">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>
											
						{elseif Product::idIsOnCategoryId($smarty.get.id_product, $cat17)}
						<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="text" min="2" name="qty" id="quantity_wanted" class="text" disabled="disabled" value="{if isset($quantityBackup)}{$quantityBackup|intval}{else}{if $product->minimal_quantity > 2}{$product->minimal_quantity}{else}2{/if}{/if}"  />
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_2">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_2">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>

						{else}
						<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" disabled="disabled" class="text" value="{if isset($quantityBackup)}{$quantityBackup|floatval}{else}{if $product->minimal_quantity > 0.5}{$product->minimal_quantity}{else}0.5{/if}{/if}" />
							<a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_down_0.5">
								<span><i class="icon-minus"></i></span>
							</a>
							<a href="#" data-field-qty="qty" class="btn btn-default button-plus product_quantity_up_0.5">
								<span><i class="icon-plus"></i></span>
							</a>
							<span class="clearfix"></span>
						</p>	

						{/if}
						{/if}
						<!-- minimal quantity wanted -->
						<p id="minimal_quantity_wanted_p"{if $product->minimal_quantity <= 1 || !$product->available_for_order || $PS_CATALOG_MODE} style="display: none;"{/if}>
							{l s='The minimum purchase order quantity for the product is'} <b id="minimal_quantity_label">{$product->minimal_quantity}</b>
						</p>

1 and 2 work fine but 0.5 nope (i tried it with min="0.5" too)

 

product.js

// The button to increment the product value
$(document).on('click', '.product_quantity_up_1', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 1).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_1', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 1)
                $('input[name='+fieldName+']').val(currentVal - 1).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(1);

        $('#quantity_wanted').change();    
});

// The button to increment the product value
$(document).on('click', '.product_quantity_up_2', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 2).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_2', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 2)
                $('input[name='+fieldName+']').val(currentVal - 2).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(2);

        $('#quantity_wanted').change();    
});

// The button to increment the product value
$(document).on('click', '.product_quantity_up_0.5', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseFloat($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 0.5).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_0.5', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseFloat($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 0.5)
                $('input[name='+fieldName+']').val(currentVal - 0.5).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(0.5);

        $('#quantity_wanted').change();    
});


if (typeof minimalQuantity !== 'undefined' && minimalQuantity)
{
	checkMinimalQuantity();
	$(document).on('keyup', 'input[name=qty]', function(e){
		checkMinimalQuantity(minimalQuantity);
	});
}

 

I appreciate any help

Edited by lvlehdi (see edit history)
Link to comment
Share on other sites

done

product.tpl 

 

<div class="product_attributes clearfix">
						<!-- quantity wanted -->
						{if !$PS_CATALOG_MODE}

						{assign cat16 [['id_category' => 16]]}
						
						{if Product::idIsOnCategoryId($smarty.get.id_product, $cat16)}
						<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="text" min="1" name="qty" id="quantity_wanted" class="text" disabled="disabled" 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_1">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_1">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>
						
						{else}
						<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" disabled="disabled" 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_2">
								<span><i class="icon-minus"></i></span>
							</a>
							<a href="#" data-field-qty="qty" class="btn btn-default button-plus product_quantity_up_2">
								<span><i class="icon-plus"></i></span>
							</a>
							<span class="clearfix"></span>
						</p>	

						{/if}
						{/if}

 

product.js

// The button to increment the product value
$(document).on('click', '.product_quantity_up_1', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 1).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_1', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 1)
                $('input[name='+fieldName+']').val(currentVal - 1).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(1);

        $('#quantity_wanted').change();    
});

// The button to increment the product value
$(document).on('click', '.product_quantity_up_2', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseFloat($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 0.5).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_2', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseFloat($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 0.5)
                $('input[name='+fieldName+']').val(currentVal - 0.5).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(0.5);

        $('#quantity_wanted').change();    
});

 

Link to comment
Share on other sites

  • 2 months later...
30.12.2016 saat 05: 55'te vekia şöyle dedi:

 

 

On 30.12.2016 at 05:55, vekia said:

Bunun eksik bir çözüm olduğunu düşünüyorum.

Ödeme sırasında hala özel bir miktar tanımlayabilirsiniz (sadece miktar alanını girmek istediğiniz herhangi bir değeri girin)

 

what do you recommend ?

 

 

Link to comment
Share on other sites

  • 2 weeks later...
On 12/8/2018 at 11:22 AM, lvlehdi said:

done

product.tpl 

 


<div class="product_attributes clearfix">
						<!-- quantity wanted -->
						{if !$PS_CATALOG_MODE}

						{assign cat16 [['id_category' => 16]]}
						
						{if Product::idIsOnCategoryId($smarty.get.id_product, $cat16)}
						<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="text" min="1" name="qty" id="quantity_wanted" class="text" disabled="disabled" 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_1">
                        	<span><i class="icon-minus"></i></span>
                        </a>
                        <a href="#" data-field-qty="qty" class="btn btn-default button-minus product_quantity_up_1">
                         	<span><i class="icon-plus"></i></span>
							</a>
						</p>
						
						{else}
						<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" disabled="disabled" 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_2">
								<span><i class="icon-minus"></i></span>
							</a>
							<a href="#" data-field-qty="qty" class="btn btn-default button-plus product_quantity_up_2">
								<span><i class="icon-plus"></i></span>
							</a>
							<span class="clearfix"></span>
						</p>	

						{/if}
						{/if}

 

product.js


// The button to increment the product value
$(document).on('click', '.product_quantity_up_1', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 1).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_1', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseInt($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 1)
                $('input[name='+fieldName+']').val(currentVal - 1).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(1);

        $('#quantity_wanted').change();    
});

// The button to increment the product value
$(document).on('click', '.product_quantity_up_2', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseFloat($('input[name='+fieldName+']').val());
        if (!allowBuyWhenOutOfStock && quantityAvailable > 0)
                quantityAvailableT = quantityAvailable;
        else
                quantityAvailableT = 100000000;
        if (!isNaN(currentVal) && currentVal < quantityAvailableT)
                $('input[name='+fieldName+']').val(currentVal + 0.5).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(quantityAvailableT);

        $('#quantity_wanted').change();
});
 // The button to decrement the product value
$(document).on('click', '.product_quantity_down_2', function(e){
        e.preventDefault();
        fieldName = $(this).data('field-qty');
        var currentVal = parseFloat($('input[name='+fieldName+']').val());
        if (!isNaN(currentVal) && currentVal > 1 && currentVal > 0.5)
                $('input[name='+fieldName+']').val(currentVal - 0.5).trigger('keyup');
        else
                $('input[name='+fieldName+']').val(0.5);

        $('#quantity_wanted').change();    
});

 

Any idea of how to do this for Prestashop 1.7.4.2???

 

Thanks!

Link to comment
Share on other sites

  • 2 weeks later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...