ZenMagick 0.9.6


org.zenmagick.model.checkout.ZMShoppingCartItem

Class ZMShoppingCartItem

ZMObject
|
+--ZMShoppingCartItem

public class ZMShoppingCartItem
extends ZMObject

A single shopping cart item.

This class can either be populated using the c'tor argument (zen-cart cart info) or implicit as done by the shopping cart service (ZMShoppingCart)

Author:
DerManoMann
Version:
$Id: ZMShoppingCartItem.php 2224 2009-05-14 04:48:22Z dermanomann $
Todo:
remove deprecated code and zenItem references

Fields inherited from org.zenmagick.ZMObject
properties_
Constructor Summary

ZMShoppingCartItem(array zenItem)

Create new shopping cart item

Method Summary
array

getAttributes()

Get selected attributes for this cart item.

string

getId()

Get the cart item id (the sku).

void

getImage()

void

getImageInfo()

float

getItemPrice(boolean tax)

Get the item price.

float

getItemTotal(boolean tax)

Get the item/line total.

void

getName()

float

getOneTimeCharge(boolean tax)

Get optional one time charges for this item.

ZMProduct

getProduct()

Get the product this item is associated with.

int

getProductId()

Get the plain product id of this item.

void

getQty()

int

getQuantity()

Get the number of items in the cart.

void

getTaxClassId()

ZMTaxRate

getTaxRate(ZMAddress address)

Get the tax rate for this item.

boolean

hasAttributes()

Check if this cart item has attributes or not.

boolean

hasOneTimeCharge()

Check if this item has a one time charge attached.

boolean

isStockAvailable()

Check stock availability for the current quantity.

private void

populateAttributes(array zenItem)

Get selected attributes for this cart item.

void

setAttributes(array attributes)

Set selected attributes for this cart item.

void

setId(string id)

Set the cart item id.

void

setItemPrice(float itemPrice)

Set the item price.

void

setOneTimeCharge(float amount)

Set optional one time charges for this item.

void

setQuantity(int quantity)

Set the quantity for this item.

Methods inherited from org.zenmagick.ZMObject
attachMethod, get, getAttachedMethods, getPropertyNames, set, singleton

Constructor Detail

ZMShoppingCartItem

public ZMShoppingCartItem(array zenItem)

Create new shopping cart item

Parameters:
zenItem - The zen-cart shopping item infos.

Method Detail

getAttributes

public array getAttributes()

Get selected attributes for this cart item.

Returns:
List of product attributes.

getId

public string getId()

Get the cart item id (the sku).

This will differ from the product id if attributes are attached to the cart item.

Returns:
The product/sku id.

getImage

public void getImage()

getImageInfo

public void getImageInfo()

getItemPrice

public float getItemPrice(boolean tax)

Get the item price.

Parameters:
tax - Optional flag to include/exlcude tax; default is true to include tax.
Returns:
The price for a single item.

getItemTotal

public float getItemTotal(boolean tax)

Get the item/line total.

Parameters:
tax - Optional flag to include/exlcude tax; default is true to include tax.
Returns:
The price for a single item.
Todo:
include onetime charge

getName

public void getName()

getOneTimeCharge

public float getOneTimeCharge(boolean tax)

Get optional one time charges for this item.

Parameters:
tax - Optional flag to include/exlcude tax; default is true to include tax.
Returns:
The amount.

getProduct

public ZMProduct getProduct()

Get the product this item is associated with.

Returns:
The product.

getProductId

public int getProductId()

Get the plain product id of this item.

For items without attributes this is going to be the same as getId(). If attributes are present, product id without any attribute hash.

Returns:
The product id.

getQty

public void getQty()

getQuantity

public int getQuantity()

Get the number of items in the cart.

Returns:
The cart quantity.

getTaxClassId

public void getTaxClassId()

getTaxRate

public ZMTaxRate getTaxRate(ZMAddress address)

Get the tax rate for this item.

Parameters:
address - Optional shipping address; default is null to use the store address.
Returns:
The tax rate or null.

hasAttributes

public boolean hasAttributes()

Check if this cart item has attributes or not.

Returns:
true if there are attributes (values) available, * false if not.

hasOneTimeCharge

public boolean hasOneTimeCharge()

Check if this item has a one time charge attached.

Returns:
true if a one time charge is set.

isStockAvailable

public boolean isStockAvailable()

Check stock availability for the current quantity.

Returns:
true if sufficient stock is available, false if not.

populateAttributes

private void populateAttributes(array zenItem)

Get selected attributes for this cart item.

Parameters:
zenItem - zc item data.
Deprecated.

setAttributes

public void setAttributes(array attributes)

Set selected attributes for this cart item.

Parameters:
attributes - List of product attributes.

setId

public void setId(string id)

Set the cart item id.

Parameters:
id - The product/sku id.

setItemPrice

public void setItemPrice(float itemPrice)

Set the item price.

Parameters:
itemPrice - The price for a single item (excl. tax).

setOneTimeCharge

public void setOneTimeCharge(float amount)

Set optional one time charges for this item.

Parameters:
amount - The amount.

setQuantity

public void setQuantity(int quantity)

Set the quantity for this item.

Parameters:
quantity - The cart quantity.

ZenMagick 0.9.6