/cart.json
Cart object returned as JSON.
For familiarity we have tried to ensure consistency in terminology with the Cart object.
Example using JQuery
jQuery.getJSON('/cart.json', function(returnValue) {
console.log(returnValue);
});
Internationalisation
If your website has multiple languages you will want to ensure results are returned in the language, country and currency of your locales. To achieve this you can localise the URL as follows.
In your EVML view file:
<div id="myDiv" data-url="@/cart.json"></div>
Within your view's JavaScript file:
var myDiv = jQuery('#myDiv');
jQuery.getJSON(myDiv.attr('data-url'), function(returnValue) {
console.log(returnValue);
} );
With the code above it won't matter which locale you visit the URL and results will be correct.
Accepted Parameters
The script allows you to define the following optional parameters.
Returned Object
The script returns an object with the following properties.
availablePostage
Returns an Array of available Postage options. |
channelCurrency
The ISO code of currency of the channel at the point of instantiation e.g. GBP or USD. |
code
|
coupon
If the cart contains a discount coupon, the Discount object
is returned.
|
created
The date the cart was created on. |
currency
The currency ISO code for the Cart object. |
discount
The total discount applied to the cart, either net or gross depending on the taxRule. |
fragment
If you specify a |
hasCutOff
Returns true if the cart's postage option has a cut off time less than the current time. This allows us to show the postage's cut-off message to the visitor. |
hasDiscount
Returns true if the cart has any discounts applied. |
id
The system ID for the cart. |
includesTax
Returns true if the cart's taxRule is set to includingTax, else false. |
isCustomShipping
Returns true if an administrator has applied custom shipping costs to a cart or order. |
isPurchasable
Returns true if a customer/visitor is able to purchase the Cart contents online, else false - the user may enquire online if the facility is available. |
isRecurring
Returns true if the cart contains a product which is of type 'Subscription'. |
isTaxExempt
Returns true if the cart has a valid taxNumber. |
isTaxExemptable
Returns true if a customer may enter a VAT number for tax exemption. |
lines
An array item for each cart line is built up containing the properties of the CartLine object. |
postageMethod
The name of the postage method. |
shipping
The total cost of shipping either net or gross depending on the taxRule. |
source
The original source of where the cart was instantiated. This property is important in segmenting order activity by:
|
subtotal
The subtotal of all lines in the cart excluding shipping and before discount. The subtotal will be either net or gross depending on the taxRule. |
tax
The total tax levied on the cart. |
taxNumber
Goods shipped within the EC, but outside the European merchant's own country may allow their customer to provide a valid VAT number. The tax registration number is stored with the order. |
taxNumberVerified
Returns true if the VAT number provided by the customer was verified.
|
taxRule
The tax rule for the cart may be:
European based consumer sites generally have a taxRule of includingTax, whilst trade or US websites prefer excludingTax rules. Note: the taxRule is independent of whether the merchant charges tax on sales. So a merchant in the United Kingdom who is not yet VAT registered may still have a tax rule of includingTax, despite no levy. |
total
The gross total for the cart. |
weight
The gross shipping weight of the cart in kg. |