[ic] how to find weight for items in cart for shipping criteria
Stefan Hornburg
racke at linuxia.de
Tue Aug 17 03:23:54 EDT 2004
On Tue, 17 Aug 2004 05:06:53 +0000
"Akash Shah" <ic_user at hotmail.com> wrote:
> hi,
>
> IC 5.2.0 - foundation based catalog
>
> I'm trying to add an offset to my shipping calculation. The reason to add
> the offset is to calcualte the weight for the shipping box. The reason to do
> this is because there are some items which ship for free and so have weight
> 0 and I don't want to add the offset to them. Here is the code I have in my
> shipping.asc
>
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
> USPSROLLED: USPS Priority Mail
> criteria <<EOF
> [perl]
> my $total = 0;
> my $tmp_weight = 0;
> foreach my $item (@$Items) {
> $tmp_weight = $Tag->field('weight', $item->{code} );
> next unless $tmp_weight > 0;
> $total += $item->{quantity} * $tmp_weight ;
> }
> if ($total > 0) {
> $total += 1.0;
> }
> return $total;
> [/perl]
> EOF
> min 0
> max 0
> cost e Free Shipping!
>
> min 0
> max 5
> cost u
> table USPSPriority
> geo zip
> default_geo xxxxx
> adder 1
>
> min 5
> max 9999999
> cost e Error!
> xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
>
> The issue here is that, I cannot access the weight for each individual item.
> It is not stored in the cart along with each item and trying to call [data]
> or [field] is throwing errors.
>
> /cgi-bin/xxx/admin/test_code.html Safe: no access for database products at
> /usr/local/interchange-5.2.0/lib/Vend/Data.pm line 1036.
>
> Any suggestions on how to get weight of each item in the code segment above
> ?
You can either use [perl tables="products"] to allow access to products
database within embedded Perl or even better add
AutoModifier weight
to your catalog.cfg.
See the documentation for more information about AutoModifier.
Ciao
Racke
--
LinuXia Systems => http://www.linuxia.de/
Expert Interchange Consulting and System Administration
ICDEVGROUP => http://www.icdevgroup.org/
Interchange Development Team
More information about the interchange-users
mailing list