Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

The AMI_EshopCart class

• Introduction

E-shop cart business layer.

• Class synopsis

AMI_EshopCart {
/* Properties */
// Instance
protected static AMI_EshopCart $oInstance;
// Array of cart items
protected array $aCartItems = array();
// Array of cart amount values
protected array $aTotal = array();
// CMS cart object
protected Cart $oCart;
/* Methods */
// Constructor.
public __construct ( ) returns AMI_EshopCart;
// Adds a cart item object.
public addCartItem ( AMI_CartItem $oCartItem ) returns AMI_EshopCart;
// Create AMI_CartItem object and adds it to cart.
public addItem ( int $itemId, [ float $qty = 1 ], [ int $priceNum = 0 ], [ int $propId = 0 ] ) returns AMI_EshopCart;
// Clears the cart, removes all items.
public clear ( ) returns AMI_EshopCart;
// Deletes a cart item.
public deleteItem ( int $itemId, [ int $priceNum = 0 ], [ int $propId = 0 ] ) returns AMI_EshopCart;
// Returns a cart item.
public getItem ( int $itemId, [ int $priceNum = 0 ], [ int $propId = 0 ] ) returns mixed;
// Returns a cart items.
public getItems ( [ int $itemId = null ], [ int $priceNum = null ], [ int $propId = null ] ) returns array;
// Returns the quantity of cart items.
public getItemsQuantity ( ) returns float;
// Calculate and returns the cart total amount values.
public getTotal ( ) returns array;
// Returns TRUE if the cart item exists.
public hasItem ( int $itemId, [ int $priceNum = 0 ], [ int $propId = 0 ] ) returns bool;
// Returns TRUE if the cart is empty.
public isEmpty ( ) returns bool;
// Recalculate the cart total amount.
public recalcTotal ( ) returns array;
// Set cart currency.
public setCurrency ( [ string $currency = '' ] ) returns AMI_CartItem;
// Sets a cart items.
public setItems ( $aCartItems ) returns array;
}

• Class Details

Allows to manage e-shop cart items.
  Example:
  •  $AMI_ENV_SETTINGS array('mode' => 'full''disable_cache' => true);
  •  require 'ami_env.php';
  •  
  •  $oEshopCart AMI::getResource('eshop/cart');
  •  
  •  // Add product to cart
  •  $oEshopCart->addItem(209100);
  •  
  •  // Get cart total amount
  •  $aTotal $oEshopCart->getTotal();
  •  
  •  // Get array of cart items objects
  •  $aCartItems $oEshopCart->getItems();
Tags:
since 6.0.2
resource eshop AMI::getSingleton('eshop/cart')

• Class Properies

protected static AMI_EshopCart $oInstance

Instance

protected array $aCartItems

Array of cart items

protected array $aTotal

Array of cart amount values

protected Cart $oCart

CMS cart object

• Class Methods

// Constructor.
public __construct ( ) returns AMI_EshopCart;
// Adds a cart item object.
public addCartItem ( AMI_CartItem $oCartItem ) returns AMI_EshopCart;
// Create AMI_CartItem object and adds it to cart.
public addItem ( int $itemId, [ float $qty = 1 ], [ int $priceNum = 0 ], [ int $propId = 0 ] ) returns AMI_EshopCart;
  • int $itemId
    Product id
  • float $qty
    Product quantity
  • int $priceNum
    Price number
  • int $propId
    Prop id
// Clears the cart, removes all items.
public clear ( ) returns AMI_EshopCart;
// Deletes a cart item.
public deleteItem ( int $itemId, [ int $priceNum = 0 ], [ int $propId = 0 ] ) returns AMI_EshopCart;
  • int $itemId
    Product id
  • int $priceNum
    Price number
  • int $propId
    Prop id
// Returns a cart item.
public getItem ( int $itemId, [ int $priceNum = 0 ], [ int $propId = 0 ] ) returns mixed;
  • int $itemId
    Product id
  • int $priceNum
    Price number
  • int $propId
    Prop id
// Returns a cart items.
public getItems ( [ int $itemId = null ], [ int $priceNum = null ], [ int $propId = null ] ) returns array;
  • int $itemId
    Product id
  • int $priceNum
    Price number
  • int $propId
    Prop id
// Returns the quantity of cart items.
public getItemsQuantity ( ) returns float;
// Calculate and returns the cart total amount values.
public getTotal ( ) returns array;
// Returns TRUE if the cart item exists.
public hasItem ( int $itemId, [ int $priceNum = 0 ], [ int $propId = 0 ] ) returns bool;
  • int $itemId
    Product id
  • int $priceNum
    Price number
  • int $propId
    Prop id
// Returns TRUE if the cart is empty.
public isEmpty ( ) returns bool;
// Recalculate the cart total amount.
public recalcTotal ( ) returns array;
// Set cart currency.
public setCurrency ( [ string $currency = '' ] ) returns AMI_CartItem;
  • string $currency
    Currency code
// Sets a cart items.
public setItems ( $aCartItems ) returns array;
  • array $aCartItems
    Array of cart items