WAStoreTask


Seaside-Examples-Store

Comment:

This task models the main application flow of the store example.  Most of the other components in the example are called from here.  The flow is defined by the #go method.  After creating a WAStoreCart instance, this calls WAStoreFillCart to allow the user to add items to it.  It then calls WAStoreCartConfirmation, WAStoreAddressEditor, and WAStorePaymentEditor in succession for the checkout process.  Many of the components it calls are wrapped with informative messages (#withMessage:) and validation (#validateWith:).  It also makes use of WASession>>isolate: to ensure that once the checkout process starts, backtracking to modify the cart is forbidden.  Used by WAStore.

Hierarchy:

ProtoObject
Object
WAPresenter
WAComponent
WATask
WAStoreTask

Summary:

instance variables:

cart

methods:

instance class
as yet unclassified no messages

Detail:

instance variables:

cart

instance methods:

as yet unclassified
confirmContentsOfCart

	^ self call:
		((WAStoreCartConfirmation new cart: cart)
			addMessage: 'Please verify your order:')
displayConfirmation

	self inform: 'Your fish is on its way.'
fillCart

	self call: (WAStoreFillCart new cart: cart)
getAddressWithMessage: aString

	^ self call:
		((WAStoreAddressEditor new
			validateWith: [:a | a validate])
				addMessage: aString)
getBillingAddress

	^ self getAddressWithMessage: 'Please enter your billing address:'.
getPaymentInfo

	^ self call:
		((WAStorePaymentEditor new
			validateWith: [:p | p validate])
				addMessage: 'Please enter your payment information:')
getShippingAddress

	^ self getAddressWithMessage: 'Please enter your shipping address:'.
go

	| shipping billing creditCard |
	cart _ WAStoreCart new.
	self isolate:
		[[self fillCart.
		self confirmContentsOfCart]
			whileFalse].

	self isolate:
		[shipping _ self getShippingAddress.
		billing _ (self useAsBillingAddress: shipping)
					ifFalse: [self getBillingAddress]
					ifTrue: [shipping].
		creditCard _ self getPaymentInfo.
		self shipTo: shipping billTo: billing payWith: creditCard].

	self displayConfirmation.
shipTo: shippingAddress billTo: billingAddress payWith: aCreditCard

	"no-op"
useAsBillingAddress: anAddress

	^ self confirm: 'Do you wish to use ', anAddress street printString, ' as your billing address?'

class methods:

^top


- made by Dandelion -