[ic] Display Quantity Discount in Flypage

Ron Phipps interchange-users@interchange.redhat.com
Wed Feb 27 01:29:00 2002


> From: interchange-users-admin@interchange.redhat.com
[mailto:interchange-
> users-admin@interchange.redhat.com] On Behalf Of Steve Graham
> 
> Hello,
> 
> I would like to display all the different quantity breaks each item
has,
> and
> if it doesn't have any don't display, in each items flypage. I have IC
> 4.8.3
> calculating the prices correctly with commonadjust, now I want to show
the
> potential buyers the qty breaks.

You are in luck, I just did this the other day for a new site :)

> I see that [item-price q1], [item-price q5] etc... will show the
breaks,
> but
> I have discounts of 1,2,3,5,6,10,12,15,20,25....various up to to 250
opr
> more.
> If an item has only breaks at say 1,6,12 then I don't want to display
all
> the redundant breaks in-between.

This usertag will output radio buttons for each quantity break and it
looks like this:

1 for $239.00
2 for $470.00 (Save $4.00 each!)

The user then can use the radio buttons to pick how many at the quantity
price they would like to purchase.  The usertag I think needs some
tweaking to use the "price" tag instead of the "data" tag, but it worked
in the cases I needed.

Call it with the following inside a flypage:

[build-pricing-selection sku="[item-code]" table="pricing"]

Have fun :)
-Ron

UserTag build-pricing-selection Order sku table
UserTag build-pricing-selection Routine <<EOR
sub {
	my ($sku, $price_db) = @_;
	my @price_breaks = (2, 3, 4, 5, 6, 7, 8, 9, 10, 12, 15, 25, 50,
100);
	my $break;
	my $break_price;
	my $orig_price;
	my $price;
	my $out = '';
	my $savings;
	
	$orig_price = $Tag->data("products", "price", $sku);
	
	for $break (@price_breaks)
	{
		$break_price = "";
		$break_price = $Tag->data($price_db, "q$break", $sku);
		
		if ($break_price != "")
		{
			$price = $break_price * $break;
			$savings = ($orig_price - $break_price);
			
			$price = $Tag->currency(0, 0, $price);
			$savings = $Tag->currency(0, 0, $savings);
			$out .= <<EOF;
				<input type="radio"
name="mv_order_quantity" value="$break">$break for $price (Save $savings
each!)<br>
EOF
		}
	}
	
	return $out;
}
EOR