[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
[ic] Discounting Entire Order based On Quantity
Fred Pope wrote:
>I am trying to discount an order based on if there are 20 or more items in
>the cart.
>
>Here is the code that I have placed on the checkout.html page located in
>$catalogroot/pages/ord/:
>
>1 [if type=explicit compare="[calc][item-quantity] > 19 [/calc]"]
>2 [discount ENTIRE_ORDER]$s * .8 [/discount]
>3 [else]
>4 [discount ENTIRE_ORDER][/discount]
>5 [/else]
>6 [/if]
>
>The discount is working fine. What is not working is the IF statement on
>line 1 that is supposed to make the adjustment only if there are more than
>19 items in the cart. I think this is because I am not using the right field
>for quantity.
>
Are you looking to discount if there are 20 or more line items more than
20 total pieces regardless of the number of line items because your
example above is looking at neither, it is testing to discount if the
line item has 20 or more pieces regardless of the rest of the order.
If you want 20 or more 'line items' you can use this usertag:
UserTag line_items Routine <<EOF
sub {
return @{$Vend::Items};
}
EOF
and if an [if] on line_items
or if you want to discount based on a total of 20 pieces for the entire
order, you might try this (haven't tested it)
UserTag total_line_items AddAttr
UserTag total_line_items Routine <<EOF4
sub {
my ($opt) = @_;
my $output;
my $cart = $Vend::Items;
my $item;
my $ttl = 0;
foreach $item (@$cart) {
$ttl .= $item->{quantity};
}
return $ttl;
}
EOF4
Barry
--
Barry Treahy, Jr * Midwest Microwave * Vice President & CIO
E-mail: Treahy@mmaz.com * Phone: 480/314-1320 * FAX: 480/661-7028