[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
[mv] Strangeness in shipping formulas
****** message to minivend-users from "Christopher P. Lindsey" <lindsey@mallorn.com> ******
You're probably all getting sick of my questions... I promise to answer
ten-fold once I understand everything. :)
I've been setting up minimum order amounts and noticed two oddities:
1. I can't seem to send multiple arguments to a subroutine from
the shipping calculations. Here's my line from shipping.asc:
2-day 2nd day air price 0 9999999 s twoday; [value state] @@TOTAL@@
Notice that [value state] and @@TOTAL@@ are space-delimited at the
end, so my function then needs to split on whitespace to extract
the arguments. Is there a better way to do this? I tried tabs,
commas, semi-colons, all to no avail.
2. My function works fine, but it also sets ship_message to the numeric
value being returned. Not a big deal, but it seems a little
strange since I'd like to reserve that for right for error messages.
The subroutine 'twoday' is listed below.
Thanks for any light that you can shed on this!
Chris
----------------------------------------------------------------------
In shipping.asc:
2-day 2nd day air price 0 9999999 s twoday; [value state] @@TOTAL@@
In catalog.cfg:
Sub <<EOF
sub twoday {
my ($args) = @_;
my ($state, $price) = split ' ', $args;
if ($state =~ /^(?:OR|ID|CA|UT|NV)$/) {
$multiplier = .20; $minimum = 10;
} elsif ($state =~ /^AK$/) {
$multiplier = .35; $minimum = 18;
} else {
$multiplier = .30; $minimum = 10;
}
return ($price * $multiplier > $minimum) ? $price * $multiplier : $minimum;
}
EOF
-
To unsubscribe from the list, DO NOT REPLY to this message. Instead, send
email with 'UNSUBSCRIBE minivend-users' in the body to Majordomo@minivend.com.
Archive of past messages: http://www.minivend.com/minivend/minivend-list