View Single Post
  #1  
Old 04-29-2006, 01:30 PM
 
gaussboy gaussboy is offline
 

Member
  
Join Date: Mar 2006
Posts: 21
 

Default drop down quantities with wholesale prices

This is a hack and not a completed modification.

When adding a product to my cart, the quantities drop down selector didn't really float my boat. It just didn't seem useful to have a drop down list that counted from 1-1000 or whatever. Why not a text input? Anyway..

It seemed especially silly when I enabled wholesale pricing, which displays a table of price breaks just beneath the drop down. So, I decided to merge the wholesale pricing into the dropdown box. It was actually pretty easy to do which leads me to wonder if I did something wrong

In skin1/customer/main/product.tpl, I changed the section of code that builds the dropdown list to incorporate the logic from skin1/customer/main/product_prices.tpl.

in skin1/customer/main/product.tpl, look for the the following:
Code:
<SELECT id="product_avail" name="amount"{if $active_modules.Product_Options ne '' && $product_options ne ''} onchange ="check_options();"{/if}> {section name=quantity loop=$mq start=$start_quantity} <OPTION value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</OPT ION> {/section} </SELECT>


and then change it to something like this:
Code:
<SELECT id="product_avail" name="amount"{if $active_modules.Product_Options ne '' && $product_options ne ''} onchang e="check_options();"{/if}> {if $product_wholesale ne ""} {section name=wholesale loop=$product_wholesale} {if $smarty.section.wholesale.first} <OPTION value="{$product.min_amount}">{$product.min_amount}for{include file="currency.tpl" value=$pro duct.taxed_price}each</OPTION> {/if} <OPTION value="{$product_wholesale[wholesale].quantity}">{$product_wholesale[wholesale].quantity}for{in clude file="currency.tpl" value=$product_wholesale[wholesale].taxed_price}each</OPTION> {/section} {/if} {if $product_wholesale eq ""} {section name=quantity loop=$mq start=$start_quantity} <OPTION value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</OP TION> {/section} {/if} </SELECT>

This creates a dropdown that lists each wholesale discount available for the product. (1 for $0.052 each, 1000 for $0.047 each, etc) and you can select the level you want to buy at and add that number to your cart. I don't use product options or variants so this was fairly simple for me. YMMV. Also, I hard coded in the "for" and the "each", which should be extracted into a lang variable.


If anyone sees any improvements or lack of foresight, please let me know.

You can see this hack at work here:
http://www.gaussboys.com/xcart/product.php?productid=1&cat=3&page=1

BTW, I did a few other cosmetic changes to the product.tpl like remove the wholesale pricing table.
__________________
Version 4.0.18
Reply With Quote