diff --git a/lib/WebGUI/Shop/PayDriver.pm b/lib/WebGUI/Shop/PayDriver.pm index cd13705e1..76e2aba4d 100644 --- a/lib/WebGUI/Shop/PayDriver.pm +++ b/lib/WebGUI/Shop/PayDriver.pm @@ -8,6 +8,7 @@ use Tie::IxHash; use WebGUI::International; use WebGUI::HTMLForm; use WebGUI::Exception::Shop; +use WebGUI::Shop::Cart; use JSON; =head1 NAME @@ -237,6 +238,23 @@ sub getButton { my $self = shift; } +#------------------------------------------------------------------- + +=head2 getCart ( ) + +Returns the WebGUI::Shop::Cart object for the current session. + +=cut + +sub getCart { + my $self = shift; + + my $cart = WebGUI::Shop::Cart->getCartBySession( $self->session ); + + return $cart; +} + + #------------------------------------------------------------------- =head2 getEditForm ( ) @@ -327,7 +345,6 @@ sub new { croak "Somehow, the options property of this object, $paymentGatewayId, got broken in the db" unless exists $properties->{options} and $properties->{options}; - #### TODO: Fix deprecated json sub my $options = from_json($properties->{options}); my $self = WebGUI::Shop::PayDriver->_buildObj($session, $class, $paymentGatewayId, $properties->{ label }, $options); @@ -366,7 +383,6 @@ flattened into JSON and stored in the database as text. There is no content che =cut -#### TODO: decide on what set() sets. Ie. does it only set options, or also label? sub set { my $self = shift; my $properties = shift; diff --git a/t/Shop/PayDriver.t b/t/Shop/PayDriver.t index 35f9784ca..70ffab7ed 100644 --- a/t/Shop/PayDriver.t +++ b/t/Shop/PayDriver.t @@ -31,7 +31,7 @@ my $session = WebGUI::Test->session; #---------------------------------------------------------------------------- # Tests -my $tests = 45; +my $tests = 46; plan tests => 1 + $tests; #---------------------------------------------------------------------------- @@ -273,6 +273,15 @@ $optionsCopy->{label} = 'And now for something completely different'; isnt ($driver->get('label'), 'And now for something completely different', 'hashref returned by get() is a copy of the internal hashref'); +####################################################################### +# +# getCart +# +####################################################################### + +my $cart = $driver->getCart; +isa_ok ($cart, 'WebGUI::Shop::Cart', 'getCart returns an instantiated WebGUI::Shop::Cart object'); + ####################################################################### # # getEditForm