
[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date
][Interchange by thread
]
Re: [ic] Totally items in cart (sum shipping cost)
"Jeffrey Carnahan" <jcarnahan@NETWORQ.COM> writes:
> } [perl arg="carts"]
> } $ship_total = 0;
> }
> } # Loop over all items in the main cart
> } foreach my $item
>
> } @{$Safe{'carts'}->{'main'}} )
> } {
> } # Total up all the shipping costs
> } $ship_total = $ship_total +
> } $item->{'shipping'};
> } }
> } return ("Shipping: $ship_total");
> } [/perl]
>
> If you have a field called 'shipping' for each product in the products
> database, and you've defined this in the products database definition, and
> you've restarted your catalog, you should be able to use the following:
>
> [perl tables="products"]
> my $` = 0;
>
> foreach $item ($Carts->{'main'}) {
> $ship_total += $Tag->data('products', 'shipping', $item->{'code'});
> }
>
> return "Shipping Total: $ship_total";
> [/perl]
>
> Note that I'm assuming the name of your products database is "products". You
> need to use the [data ... ] tag here because arbitrary fields associated
> with products (such as the "shipping" field you've defined) aren't kept with
> the shopping cart information. Only quantity, code, options, and DB source
> information are kept in the cart.
If its the products database, you may abbreviate like this:
$ship_total += $Tag->field('shipping', $item->{'code'});
Ciao
Racke
--
Racke happily hacks Interchange and maintains Debian packages like Courier.
For projects and other business stuff please refer to COBOLT NetServices
(URL: http://www.cobolt.net; Email: info@cobolt.net; Phone: 0041-1-3884400)
_______________________________________________
interchange-users mailing list
interchange-users@interchange.redhat.com
http://interchange.redhat.com/mailman/listinfo/interchange-users