If you have a comment on this topic, contact Aptify Documentation. If you want to return to the Aptify Community Site, please click here.

Shopping Cart

The shopping cart for the current user should always be retrieved with the Ensure Active Cart Exists process flow.  This process flow will create the Web Shopping Carts record for the user if it doesn't exist and create a default order object.  There is a rule step for assigning default values on the order.  The order backing the cart is not persisted to the Orders entity until checkout when payment is applied. The Web Shopping Carts entity plugin is responsible for syncing the order XML to its record.  If changes are made to the shopping cart's order as a result of business logic, you should always save the cart to persist the XML.  

Working with the cart

Remember: retrieve the cart, manipulate the order, save the cart. When in doubt look at what existing stock endpoints are doing.

Determining the Current Users Cart

A user can only have one active cart at a time.  The active cart is one that is Open status and is either:

  • linked to the authenticated user through the WebUserId field on the Web Shopping Cart record
  • linked to the anonymous user through the TokenId field on the Web Shopping Cart Record.  

If the system finds that more than one active cart exists for the current user an illegal state exception will be thrown during Ensure Active Cart Exists.  

Anonymous Shopping

A user does not need to be authenticated to add to their cart.  Aptify now assigns unique anonymous tokens to unauthenticated users.  These tokens are assigned to the cart in the TokenId field as part of the Ensure Active Cart Exists process flow.  When an anonymous user converts to an authenticated user the global event AfterServicesLogon is fired.  A synchronous event handler takes care of updating the cart associated with the current anonymous token to the newly authenticated user.  If the user already had an active cart associated with their web user id, that cart is moved to Saved status so the current shopping experience is preserved.  

Sensitive Data in the Order

Since we're serializing the order to plain text XML and storing it on the shopping cart record, it is imperative the shopping cart entity plugin stops sensitive data from being written out.  If the order has payment information written out the Web Shopping Cart entity plugin will reject the save.  The stock system looks for:

  • CCAccountNumber being populated on the Order
  • PaymentInformationID being > 0 on the order
  • the _xCCSecurityNumber temporary field being set

If there is additional information on your order related to payments, you should extend the Web Shopping Cart entity plugin and add additional checks.


Copyright © 2014-2019 Aptify - Confidential and Proprietary