Jump to content

Quantity as dropdown


sickshot

Recommended Posts

Edit file themes/<your theme folder>/product.tpl   (Make backup!!)

 

 

Find code below (almost halfway the file, search for quantity wanted) and add red code: (Sample code from PS 1.6.0.14)

 

 

  <!-- quantity wanted -->
  {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>{l s='Quantity'}</label>
      <select name="qty" id="quantity_wanted">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="4">4</option>
          <option value="8">8</option>
      </select>
      {*          <-- to comment out the original quantity input method
        <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}" />
        <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>
      *}       <-- to comment out the original quantity input method
      <span class="clearfix"></span>
    </p>
  {/if}
  <!-- minimal quantity wanted -->
 

 

Result:

post-455771-0-26228700-1432781504_thumb.png

post-455771-0-38491100-1432781515_thumb.png

 

 

N.B. Change the drop down item values as needed in the code above:

          <option value="1">1</option>
 

 

Hope this helps,

pascal

 

 

Link to comment
Share on other sites

  • 3 weeks later...

If you want to use multiples of a defined value, you can insert the value in the "UPC barcode" field and use this code:

{if $product->upc == ''}
	<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}" />
	<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>
{else}
	<select name="qty" id="quantity_wanted">
		{section name=foo start=$product->upc loop=10000 step=$product->upc max=12}
			<option value="{$smarty.section.foo.index}">{$smarty.section.foo.index}</option>
			{$smarty.section.foo.index}
		{/section}
	</select>
{/if}

k2b8uc.png

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

  • 1 year later...

Great!

 

What if I wish to take the fixed values for each product from say using a child table to products table. For example: Product-1 has quantity options as 1,2,3 & 4 and product-2 has quantity options as 2,4,6,8 & 10. In short, I wish to not take them as multiples of some number but those as defined in the child table.

 

Actually, I am trying to make Prestashop to accept the quantities in decimal fractions as 0.25, 0.5, 0.75 & 1.0 or 0.2 & 0.4.

 

PS 1.6.0.9.

 

Sorry for reopening this thread after a long time again and Thanks in advance for all help in this regards.

Link to comment
Share on other sites

  • 1 month later...

Edit file themes/<your theme folder>/product.tpl   (Make backup!!)

 

 

Find code below (almost halfway the file, search for quantity wanted) and add red code: (Sample code from PS 1.6.0.14)

 

 

  <!-- quantity wanted -->
  {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>{l s='Quantity'}</label>
      <select name="qty" id="quantity_wanted">
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="4">4</option>
          <option value="8">8</option>
      </select>
      {*          <-- to comment out the original quantity input method
        <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}" />
        <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>
      *}       <-- to comment out the original quantity input method
      <span class="clearfix"></span>
    </p>
  {/if}
  <!-- minimal quantity wanted -->
 

 

Result:

attachicon.gifquantity dropdown.png

attachicon.gifquantity dropdown opened.png

 

 

N.B. Change the drop down item values as needed in the code above:

          <option value="1">1</option>
 

 

Hope this helps,

pascal

 

It works in 1.6.1.4 version? I tried but not working for me... :(

Link to comment
Share on other sites

My solution to this was to make Quantity an attribute and then remove the original quantity from appearing anywhere where the customer can see or change it -- so all orders are for quantity 1 as far as PrestaShop is concerned and then attribute Quantity sets the actual order quantity.

 

The main reason for doing it this way is that it allows different defined quantities for different products.   

Link to comment
Share on other sites

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...