Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls

drop down quantities with wholesale prices

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #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
  #2  
Old 06-28-2006, 02:35 AM
 
balinor balinor is offline
 

Veteran
  
Join Date: Oct 2003
Location: Connecticut, USA
Posts: 30,253
 

Default

Moving to Custom Mods...a hack is still a mod
__________________
Padraic Ryan
Ryan Design Studio
Professional E-Commerce Development
Reply With Quote
  #3  
Old 09-21-2006, 12:41 PM
 
Cpt.Crashtastic Cpt.Crashtastic is offline
 

eXpert
  
Join Date: Jan 2006
Posts: 219
 

Default Re: drop down quantities with wholesale prices

I've tried this on version 4.1.3

It's working to a point.

http://www.embroideredcaps.info/4175-Brushed-Heavy-Cotton-with-Piping-Tri-Colour-p-12.html

Should I be telling smarty something so it doesn't display more values than available from the wholesale quantitys table?

regards

Ant
__________________
Xcart 4.4.?
Xcart Next
Litecommerce with Drupal
http://www.corbywebworx.com

Custom Mods, Hosting and Support for Xcart-Next and LiteCommerce
Reply With Quote
  #4  
Old 04-11-2008, 03:43 AM
 
mattia mattia is offline
 

Member
  
Join Date: May 2004
Location: rome, italy
Posts: 24
 

Default Re: drop down quantities with wholesale prices

thanks gaussboy, works nicely, although I have 2 problems:

1) In product detail page the product only has 2 wholesale prices defined (qty= 2 and qty=3+). The drop down only shows the items as they should for qty=1, 2 and 3, but not for the remaining (4, 5, etc).

2) I'd like to add the same facility to the catalog pages (skin1/customer/main/products.tpl). I located the same hunk, replaced with yours but it doesn't work. Any ideas why?

Here's what I have:

----------------------------

{assign var="start_quantity" value=$product.min_amount}
{/if}
<option value="0">0</option>

{* Original quantity drop down START

{section name=quantity loop=$mq start=$start_quantity}
<OPTION value="{%quantity.index%}" {if $smarty.get.quantity eq %quantity.index%}selected{/if}>{%quantity.index%}</OPTION>
{/section}

Original quantity drop down END *}

{* MODIFIED quantity drop down START *}

{if $product_wholesale ne ""}
{section name=wholesale loop=$product_wholesale}
{if $smarty.section.wholesale.first}
<OPTION value="{$product.min_amount}">{$product.min_amount }x{include file="currency.tpl" value=$product.taxed_price}{$lng.lbl_each}</OPTION>
{/if}
<OPTION value="{$product_wholesale[wholesale].quantity}">{$product_wholesale[wholesale].quantity}x{include file="currency.tpl" value=$product_wholesale[wholesale].taxed_price}{$lng.lbl_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%}</OPTION>
{/section}
{/if}

{* MODIFIED quantity drop down END *}

</SELECT>
{/if}
</TD>

----------------------------

Thanks, nice hack!
__________________
------------------------
X-Cart: 4.0.15 Gold
Apache 2.0.52 / PHP 4.4.6 / MySQL Server: 4.1.22-standard-log, client: 5.0.27
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 12:21 PM.

   

 
X-Cart forums © 2001-2020