Class: Cart



Properties


$items = array ()

  • Access: public

The list of items in the cart. Keys are the sku's, values are
Item objects.


$tax = 1.0

  • Access: public

The tax is a number that the prices are simply multiplied by,
so to assign 15% tax, you would set $tax to 1.15


$price_column = 'price'

  • Access: public

In order to calculate subtotals and totals, Cart needs to know
which property of Item contains the prices of the items. This defaults
to 'price'.


$customer_id = ''

  • Access: public

To identify a customer, we assign them a $customer_id. This
can be generated randomly, set to be some other identifying value,
such as the $session object's id property, or whatever you want.


$view_tpl = '<a href="{link}">View Cart</a>'

  • Access: public

If you call the view_button () method, it uses this template
to generate a 'View Cart' link.


$checkout_tpl = '<a href="{link}">Check Out</a>'

  • Access: public

If you call the checkout_button () method, it uses this
template to generate a 'Check Out' link.


$link = '/index'

  • Access: public

This property is necessary in order to create a proper
'View Cart' or 'Check Out' link with the view_button () and
checkout_button () methods.

Return to Top



Methods


Cart ($customer_id = '')

  • Access: public

Constructor method.


total_items ($tpl)

  • Access: public

Returns the number of items in the cart.


subtotal ($tpl)

  • Access: public

Adds up all of the prices of the items, not including taxes.


add_tax ($tpl)

  • Access: public

Returns the total of the prices, plus taxes.


view_button ($tpl)

  • Access: public

Generates a 'View Cart' button. Requires a global
$simple SimpleTemplate object.


checkout_button ($tpl)

  • Access: public

Generates a 'Check Out' button.


&add_item ($sku, $item)

  • Access: public
  • Return: object

Adds an item to the cart.


store ()

  • Access: public

Empty method - to be defined when subclassed. Store the cart
somewhere for another script to retrive it.


retrieve ()

  • Access: public

Empty method - to be defined when subclassed. Retrive the cart
from wherever it was stored before.


checkout ()

  • Access: public

Empty method - to be defined when subclassed. Check the person
out, we have led them to buy.


save ()

  • Access: public

Empty method - to be defined when subclassed. Save the cart for
later, without purchasing anything. Sort of a 'save as wishlist' option.


valid ()

  • Access: public

Empty method - to be defined when subclassed. Check if the
information (contact, credit cart, whatever) provided is valid.


error ()

  • Access: public

Empty method - to be defined when subclassed. Report
something gone wrong.

Return to Top

Copyright © 2008 Sitellite CMS Project

Powered by Sitellite 5.0 Content Management System