Variables · Data Types
Overview
Vanilo Cloud has several structured data types that can be used in Storefront Templates, Notifications and Emails.
Address
Addresses are used at various occasions, like checkout, orders, accounts, etc.
An address object has the following structure:
Field | Details |
---|---|
email |
null or string, the email address |
phone |
null or the phone number |
firstname |
The given name |
lastname |
The family name |
company_name |
null or the company name |
tax_nr |
null or the tax number when representing a company |
registration_nr |
null or the trade reg no. of the company |
country_id |
The country code eg. "NL" |
postalcode |
null or string eg. "2282 NP" |
city |
City eg. "Rijswijk" |
street_address (billing address only) |
Street address eg. "Tulpstraat 109." |
address (shipping address only) |
Street address eg. "Tulpstraat 109." |
address2 |
null or additional address details |
access_code |
null or code to access a PUDO (locker) or building |
The Cart
The cart is a special object, that is globally available in every storefront template, regardless of their context.
It's not a variable, but a global object that can be accessed via the cart()
function or the Cart
facade
(Blade only).
The following methods are available on the cart object:
Method | Details |
---|---|
itemCount() |
The number of items in the cart |
getItems() or items |
The collection of cart items |
Cart Item
Every cart item represents a single line in the cart, and has the following structure:
Field/Method | Details |
---|---|
product |
Product, the simple product or variant |
quantity |
int, the quantity of the product in the |
total |
float, the total price of the cart item (product price * quantity) |
hasConfiguration() |
bool, whether the cart item has a custom configuration associated |
doesntHaveConfiguration() |
bool, the opposite of hasConfiguration() |
configuration() |
array or null, the custom configuration of the item |
Checkout
The checkout object represents an ongoing checkout and has the following attributes/methods:
Field/Method | Details |
---|---|
getBillpayer() |
The billpayer object |
getShippingAddress() |
An Address object |
getShipToBillingAddress() |
Boolean, indicates whether the "ship to billing address" checkbox is checked |
getShippingAmount() |
A DetailedAmount object |
getTaxesAmount() |
A DetailedAmount object |
total() |
The checkout total eg. "199.90" |
getTaxesAmount() |
The total of the taxes on the order "49.90" |
getShippingAmount() |
The total of the shipping fees on the order "7.90" |
getState() |
One of virgin , started , ready or completed |
Detailed Amount
A detailed amount is a data transfer object, and is used in situations where a single numeric amount has additional information, and/or can be broken down into sub-amounts.
Method | Details |
---|---|
getValue() |
The amount as a number (float) |
getDetails() |
An array of the details. Each entry contains an array that has title (string) and amount (float) fields |
getDetail($title) |
Return the value of a single detail by title. Returns a floating point value or null if the detail is not present |
Example:
$taxes->getValue();
// => 30.00
$taxes->getDetails();
// => [
// ['title' => '19%', 'value' => '25.70'],
// ['title' => '9%', 'value' => '4.30'],
// ]
$taxes->getDetail('19%');
// => 25.70
$taxes->getDetail('9%');
// => 4.30
$taxes->getDetail('5%');
// => NULL
Product
Vanilo handles 3 different types of products: (simple) products, master products and master product variants. Only simple products and variants can be added to the cart and therefore be ordered. Master products are for holding a set of variants, that are in fact the same product but in a different size, color, etc.
Field/Method | Details |
---|---|
id |
numeric string, the product id |
sku |
string, Stock Keeping Unit (master products DO NOT have SKU) |
name |
string, the name of the product. See also the product_title() helper |
price |
float, the price of the product |
original_price |
null or float, the original, or crossed-out price of the product |
stock |
integer, the current stock |