ZMObject
|
+--ZMShoppingCart
public class ZMShoppingCart
extends ZMObject
| Constructor Summary | |
|---|---|
Create new instance. |
|
| Method Summary | |
|---|---|
| boolean | addProduct(int productId, int quantity, array attributes, boolean notify) Add a product in the given quantity. |
| The | adjustQty(mixed quantity) Adjust the quantity based on the quantity settings. |
| static int | base_product_id(string productId) Extract the base product id from a given string. |
| int | Checks for free products in the cart. |
| boolean | Checks for free shipping. |
| ZMAddress | Get the selected billing address. |
| string | Get the customer comment. |
| array | Get list of available credit types; eg promo codes, etc. |
| array | getItems() Get the items in the cart. |
| mixed | getOrderFormContent(boolean echo) Returns the order form elements. |
| string | Returns the URL for the actual order form. |
| int | Get the id of the selected payment method. |
| ZMPaymentType | Get the selected payment type. |
| array | Get a list of the available payment types. |
| string | getPaymentsJavaScript(boolean echo) Generate the JavaScript for the payment form validation. |
| int | getQty(string productId, mixed isQtyMixed, boolean qtyMixed) Get the cart quantity for the given product. |
| ZMAddress | Get the current shipping address. |
| mixed | Get the selected shipping method. |
| int | Get the selected shipping method id. |
| int | getSize() Get the size of the cart. |
| ZMAddress | Get the tax address for this cart. |
| float | getTotal() Get the cart total. |
| array | Get the order totals. |
| float | Get the carts weight. |
| boolean | Checks if the cart has a billing address. |
| boolean | Check for out of stock items. |
| boolean | Checks if the cart has a shipping address. |
| boolean | isEmpty() Check if the cart is empty. |
| boolean | isGVOnly() Checks if there are only gift vouchers in the cart. |
| boolean | Check for virtual cart. |
| array | prepare_uploads(ZMProduct product, array attributes) Prepare file uploads. |
| static string | product_variation_id(string productId, mixed attributes, array attrbutes) Reverse of base_product_id. |
| boolean | Check whether the cart is ready for checkout or not. |
| boolean | removeProduct(string productId) Remove item from cart. |
| array | sanitize_attributes(ZMProduct product, array attributes) Sanitize the given attributes and add default values if attributes/values invalid/missing. |
| void | setBillingAddressId(int addressId) Set the selected billing address. |
| void | setShippingAddressId(int addressId) Set the current shipping address id. |
| boolean | updateProduct(string cartProductId, int quantity, boolean notify) Update item. |
| int | Checks for virtual products in the cart. |
| Methods inherited from org.zenmagick.ZMObject | |
|---|---|
| backtrace, create, log, singleton | |
public ZMShoppingCart()
Create new instance. /
public boolean addProduct(int productId, int quantity, array attributes, boolean notify)
Add a product in the given quantity.
Doesn't support uploads (yet).
If isSanitizeAttributes is set to true, missing
attributes will be added automatically and set to defaults.
1.ZMAttributeValue; default is an empty array.truetrue if the product was added, false if not.public The adjustQty(mixed quantity)
Adjust the quantity based on the quantity settings.
public static int base_product_id(string productId)
Extract the base product id from a given string.
public int freeProductsCount()
Checks for free products in the cart.
public boolean freeShippingCount()
Checks for free shipping.
true if the cart is free of shipping.public ZMAddress getBillingAddress()
Get the selected billing address.
public string getComment()
Get the customer comment.
public array getCreditTypes()
Get list of available credit types; eg promo codes, etc.
NOTE: This is also using ZMPaymentType as class
to handle the data. Only difference is that the payment type is used to reduce
the cart total.
ZMPaymentType instances.public array getItems()
Get the items in the cart.
ZMShoppingCartItems.public mixed getOrderFormContent(boolean echo)
Returns the order form elements.
true, echo the code.public int getPaymentMethodId()
Get the id of the selected payment method.
public ZMPaymentType getPaymentType()
Get the selected payment type.
public array getPaymentTypes()
Get a list of the available payment types.
ZMPaymentType instances.public string getPaymentsJavaScript(boolean echo)
Generate the JavaScript for the payment form validation.
true, echo the code.public int getQty(string productId, mixed isQtyMixed, boolean qtyMixed)
Get the cart quantity for the given product.
false.public ZMAddress getShippingAddress()
Get the current shipping address.
public mixed getShippingMethod()
Get the selected shipping method.
public int getShippingMethodId()
Get the selected shipping method id.
public int getSize()
Get the size of the cart.
NOTE: This is the number of line items in the cart, not the total number of products.
public ZMAddress getTaxAddress()
Get the tax address for this cart.
public float getTotal()
Get the cart total.
public array getTotals()
Get the order totals.
ZMOrderTotal instances.public float getWeight()
Get the carts weight.
public boolean hasBillingAddress()
Checks if the cart has a billing address.
true if there is a billing address, false if not.public boolean hasOutOfStockItems()
Check for out of stock items.
true if the cart contains items that are out of stock,
* false if not.public boolean hasShippingAddress()
Checks if the cart has a shipping address.
true if there is a shipping address, false if not.public boolean isEmpty()
Check if the cart is empty.
true if the cart is empty, false if the cart is not empty.public boolean isGVOnly()
Checks if there are only gift vouchers in the cart.
true if only vouchers are in the cart.public boolean isVirtual()
Check for virtual cart.
true if the cart is purely virtual.public array prepare_uploads(ZMProduct product, array attributes)
Prepare file uploads.
Check for uploaded files and prepare attributes accordingly.
public static string product_variation_id(string productId, mixed attributes, array attrbutes)
Reverse of base_product_id.
Creates a unique id for the given product variation.
Attributes are sorted using krsort(..) so to be compatible
for different attribute orders.
zen_get_uprid(..)...public boolean readyForCheckout()
Check whether the cart is ready for checkout or not.
true if the cart is ready or checkout, false if not.public boolean removeProduct(string productId)
Remove item from cart.
true if the product was removed, false if not.public array sanitize_attributes(ZMProduct product, array attributes)
Sanitize the given attributes and add default values if attributes/values invalid/missing.
public void setBillingAddressId(int addressId)
Set the selected billing address.
public void setShippingAddressId(int addressId)
Set the current shipping address id.
public boolean updateProduct(string cartProductId, int quantity, boolean notify)
Update item.
truetrue if the product was updated, false if not.public int virtualProductsCount()
Checks for virtual products in the cart.
Shopping cart.
This is assuming a properly configured zen cart.