Cart
The Cart class is the core of Fountain. Using it and making updates require you to keep know the structure. It keeps track of UUID for products and only keeps one license for each entity.
addProduct()
$cart->addProduct( $uuid, $uri, $licenses, $addons );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
uri |
String (optional) | URI of the font page |
licenses |
Array (required) | List of license IDs to add |
addons |
Array (required) | List of addon IDs to add |
Returns: void
Adds a product to the cart or updates an existing one. Throws InvalidArgumentException
if product data is invalid.
removeProduct()
$cart->removeProduct( $uuid );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page to remove |
Returns: void
Removes a product from the cart.
removeLicense()
$cart->removeLicense( $uuid, $license );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
license |
String (required) | License ID to remove |
Returns: void
Removes a specific license from a product in the cart.
removeAddon()
$cart->removeAddon( $uuid, $addon );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
addon |
String (required) | Addon ID to remove |
Returns: void
Removes a specific addon from a product in the cart.
getProducts()
$cart->getProducts();
Returns: Collection
Retrieves all products in the cart with their licenses and addons as a Kirby Collection of objects.
getNumItems()
$cart->getNumItems();
Returns: int|null
Gets the number of items in the cart. Returns null if the cart is empty.
getProductLicenses()
$cart->getProductLicenses( $uuid );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
Returns: array
Returns an array of license IDs for the specified product.
hasProduct()
$cart->hasProduct( $uuid );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
Returns: bool
Checks if a product is in the cart.
hasLicense()
$cart->hasLicense( $uuid, $licenses );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
licenses |
Array or String (optional) | License ID(s) to check |
Returns: bool
Checks if product already has the specified license(s).
hasSiblingLicense()
$cart->hasSiblingLicense( $uuid, $license );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
license |
String (required) | License ID to check for siblings |
Returns: string|false
Checks if license has a sibling in the cart. Returns the sibling license ID or false.
hasAddon()
$cart->hasAddon( $uuid, $addons );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
addons |
Array or String (optional) | Addon ID(s) to check |
Returns: bool
Checks if product already has the specified addon(s).
updateProduct()
$cart->updateProduct( $uuid, $uri, $licenses, $addons );
Name | Type | Info |
---|---|---|
uuid |
String (required) | UUID of the font page |
uri |
String (optional) | URI of the font page |
licenses |
Array (optional) | License IDs to update |
addons |
Array (optional) | Addon IDs to update |
Returns: void
Updates a product in the cart. Merges new licenses and addons with existing ones. For entity license type, automatically removes sibling licenses.
clearEmptyLicenses()
$cart->clearEmptyLicenses();
Returns: array
Removes all items from the cart that have no licenses. Returns array of removed items.
clearCart()
$cart->clearCart();
Returns: void
Empties the entire cart and removes cart data from session.
getLicensee()
$cart->getLicensee();
Returns: string|false
Gets the current licensee. Returns false if not set.
setLicensee()
$cart->setLicensee( $licensee );
Name | Type | Info |
---|---|---|
licensee |
String (required) | Licensee name |
Returns: bool
Sets the licensee. Throws Exception
if licensee is not a string.
getSubtotal()
$cart->getSubtotal();
Returns: float
Calculates the subtotal of the cart based on the current license type, including all products, licenses, and addons.
getPaddleCartData()
$cart->getPaddleCartData();
Returns: array
Returns cart data formatted for Paddle, including licensee and items array.
getTitle()
$cart->getTitle();
Returns: string
Gets a comma-separated string of all font titles in the cart, truncated to 198 characters.
getPassthrough()
$cart->getPassthrough();
Returns: string
Returns JSON-encoded passthrough data for Paddle, including licensee and items.
countries()
$cart->countries();
Returns: array
Returns an associative array of supported countries (code => name).