[Date Prev][Date Next][Thread Prev][Thread Next][Minivend by date
][Minivend by thread
]
Re: Shipping _syntax_ proposal (Was Re: UPS Shipping Returns $0.00 (Continue))
Quoting Kyle Hayes (kyle540@quicknet.net):
> > expert_shipping Shipping [my-criteria] 0 99999999 f [my-shipping]
>
> Hmm, this is simpler...
Not only that, you can have a series of modes that are set by the criterion:
default Shipping - one size fits all [ship-mode] 0 0 e Contact Factory
default FedEx placeholder 1 1 f [fedex based_on=weight]
default UPS Ground placeholder 2 2 f [ups based_on=weight table=Ground]
default DHL Ground placeholder 3 3 f [dhl expedite="[value expedite]"]
UserTag ship-mode Routine <<EOR
sub {
if($::Values->{shipping_wanted} eq 'UPS' and $Values->{country} eq 'US') {
return 1;
}
elsif (etc()) {
return 2;
}
}
EOS
Again, I believe the mechanisms are all there.
> code value
>
> default You lose homeboy.
> error Houston, we have a problem
> upsg [ups type=Ground weight="@@TOTAL"]
> upsgi [ups_insured type=Ground weight="@@TOTAL@@"]
> dhl [dhl state=[value state] country=[value country]]
> ...
>
>
> Look up the shipping type. If not found, use default. If found,
> interpolate the "value" column.
That is essentially what is going on here. It might perhaps be
nice to set up some conditionals, but you can do almost anything
as it is.
The only thing that is changing about all of this in MV4 at
this point is that:
1. I will have a "z" identifier that is the same as "f" but
goes on to the next shipping mode if the cost is zero.
2. I will specify a syntax for defining a subroutine right
in the shipping file, one that uses the new [perl] -- [calc] --
[mvasp] object framework. Plus you can do neat things like:
[perl global=1]
$Tag->locale_format('0');
my $subtotal = $Tag->subtotal();
$query = <<EOF
SELECT shipmode FROM shipping
WHERE country LIKE country
and minimum >= $subtotal
EOF
$ary = $Tag->query($query);
foreach $ref (@$ary) {
my $mode = $ref->[0];
my $prelim = $Tag->shipping($mode);
next if $prelim <= 0;
push @out, $mode;
}
$Scratch->{shipmodes} = join "\n", @out;
return;
[/perl]
<SELECT NAME=mv_shipmode>
[loop list="[scratch shipmodes]" option=mv_shipmode]
<OPTION VALUE="[loop-code]"> [shipping-desc [loop-code]]
[/loop]
</SELECT>
In the unlikely category, I have thought of doing a shipping "wizard"
that would query about shipping types and produce tables based on country, weight,
mode, price, etc. I don't mind the coding there so much as I do developing
the questions. 8-)
>
> I am not sure about the @@TOTAL@@ stuff. It would probably be better to
> be able to specify tags that do this:
>
> [sum-items field="weight"]
> [sum-items field="quantity"]
UserTag does that one real easy.
UserTag sum-items Order field
UserTag sum-items Routine <<EOR
sub {
my $field = shift;
my $total = 0;
foreach my $item (@$Vend::Items) {
if (defined $item->{$field}) {
$total += $item->{$field};
}
else {
$total += product_field($field, $item->{code});
}
}
return $total;
}
EOR
I have thought about enhancing the [on-change] tag to do something
like this for reporting.
--
Mike Heins http://www.minivend.com/ ___
Internet Robotics |_ _|____
131 Willow Lane, Floor 2 | || _ \
It's a little-known fact Oxford, OH 45056 | || |_) |
that the Y1K problem caused <mikeh@minivend.com> |___| _ <
the Dark Ages. -- unknown 513.523.7621 FAX 7501 |_| \_\