From d47d2f2a9c8a8df1e8011acb7272fb2a76bde581 Mon Sep 17 00:00:00 2001 From: JT Smith Date: Thu, 13 Mar 2008 20:31:32 +0000 Subject: [PATCH] a couple new methods to make things easier --- lib/WebGUI/Shop/Cart.pm | 32 +++++++++++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/WebGUI/Shop/Cart.pm b/lib/WebGUI/Shop/Cart.pm index d47752688..5609ff067 100644 --- a/lib/WebGUI/Shop/Cart.pm +++ b/lib/WebGUI/Shop/Cart.pm @@ -198,7 +198,7 @@ sub getId { =head2 getItem ( itemId ) -Returns a reference to a WebGUI::Cart::Item object. +Returns a reference to a WebGUI::Shop::CartItem object. =head3 itemId @@ -231,6 +231,19 @@ sub getItems { #------------------------------------------------------------------- +=head2 getShipper () + +Returns the WebGUI::Shop::ShipDriver object that is attached to this cart for shipping. + +=cut + +sub getShipper { + my $self = shift; + return WebGUI::Shop::Ship->new($self->session)->getShipper($self->get("shipperId")); +} + +#------------------------------------------------------------------- + =head2 getShippingAddress () Returns the WebGUI::Shop::Address object that is attached to this cart for shipping. @@ -244,6 +257,20 @@ sub getShippingAddress { #------------------------------------------------------------------- +=head2 getTaxes () + +Returns the tax amount on the items in the cart. + +=cut + +sub getTaxes { + my $self = shift; + my $tax = WebGUI::Shop::Tax->new($self->session); + return $self->formatCurrency($tax->calculate($self)); +} + +#------------------------------------------------------------------- + =head2 new ( session, cartId ) Constructor. Instanciates a cart based upon a cartId. @@ -421,7 +448,6 @@ sub www_view { } push(@items, \%properties); } - my $tax = WebGUI::Shop::Tax->new($self->session); my %var = ( %{$self->get}, items => \@items, @@ -455,7 +481,7 @@ sub www_view { else { $var{hasShippingAddress} = 1; $var{shippingAddress} = $address->getHtmlFormatted; - $var{tax} = $self->formatCurrency($tax->calculate($self)); + $var{tax} = $self->getTaxes; my $options = WebGUI::Shop::Ship->getOptions($self); my %formOptions = (); my $defaultOption = "";