X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   drop down quantities with wholesale prices (https://forum.x-cart.com/showthread.php?t=21454)

gaussboy 04-29-2006 01:30 PM

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.

balinor 06-28-2006 02:35 AM

Moving to Custom Mods...a hack is still a mod :)

Cpt.Crashtastic 09-21-2006 12:41 PM

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

mattia 04-11-2008 03:43 AM

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!


All times are GMT -8. The time now is 04:34 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.