Interchange Developer Resource


[Date Prev][Date Next][Thread Prev][Thread Next][Interchange by date ][Interchange by thread ]

RE: [ic] Totally items in cart (sum shipping cost)



}                         [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.

The above code is untested, but should give you a starting point.

--
Jeff Carnahan - jcarnahan@networq.com

_______________________________________________
interchange-users mailing list
interchange-users@interchange.redhat.com
http://interchange.redhat.com/mailman/listinfo/interchange-users


Search for: Match: Format: Sort by: