
[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] Help with custom shipping
Thanks, Kyle! You got me started on the right foot again. Your sample
was close to what I started with, but I wasn't quite there. And I spent
all day working away from it.
Here's what finally did the trick:
### In etc/after.cfg:
UserTag bgcalc Routine <<EOR
sub{
package Vend::Interpolate;
my $cart = $Vend::Items;
my ($yn, $qt);
my $charge = 0;
foreach my $item (@{$cart}) {
$yn = Vend::Interpolate::tag_data('products',
'ship_charge',
$item->{code},);
$qt = $item->{quantity};
$charge += $qt if($yn =~ /^y/i);
}
return $charge;
}
EOR
### In products/shipping.asc:
bgship Standard quantity 0 0 e Nothing to ship!
bgship Standard quantity 0 999999 f [bgcalc] *
[var SHIP_FLAT_DOM_RATE] {'PriceDivide' => "1",}
###
I am still unclear on why the "package Vend::Interpolate;" line is
necessary, but until I added that line (based on a message I dug out of
the archives,
http://interchange.redhat.com/archive/interchange-users/2000/msg09618.html
-- thanks, Joachim!) I was getting shipping rates of around
$400,000,000.00. Not what I was after, and I presume the result of
pulling random data from some undefined space...
If someone can elucidate, please feel free.
Thanks again,
--Moe Pitman
Lone Star Internet
Kyle Cook wrote:
> At 03:15 PM 10/23/01, you wrote:
>
>> Help! I have been trying to write a custom shipping formula, wiht no
>> luck. Here's the info:
>>
>> products database has an additional field called ship_charge, set to
>> Yes/No
>>
>> Shipping should be charged at a $3 flat rate per item for thos marked
>> yes, no shipping charge for those marked no.
>>
>> [snip!]
>
>
> 2 things:
>
> 1. your usertag is defined as bgcalc, but in shipping.asc you refer to
> bgship.
>
> 2. Maybe this will help, not tested but should show how to get the
> field data you need:
>
> UserTag bgcalc Order cart
> UserTag bgcalc Routine <<EOR
> sub {
> my ($name) = @_;
> my $cart = ($name) ?
> $Vend::Session->{carts}{$name} : $Vend::Items;
> return 0 unless $cart; # and or log error...
> my $charge = 0;
> foreach my $item (@$cart) {
> $yn = Vend::Interpolate::tag_data(
> 'products',
> "ship_charge",
> $item->{code},);
> $charge++ if ($yn =~ /^y/i);
> }
> return $charge;
> }
>
> Good Luck,
> Kyle Cook
>
>
>
>
>
>
> _______________________________________________
> interchange-users mailing list
> interchange-users@interchange.redhat.com
> http://interchange.redhat.com/mailman/listinfo/interchange-users
_______________________________________________
interchange-users mailing list
interchange-users@interchange.redhat.com
http://interchange.redhat.com/mailman/listinfo/interchange-users