Skip to main content

Types

Product types

type Product = {
id: number,
title: string,
description: string,
supplier: string,
sku: string,
quantity: number,
optionsEnabled: boolean,
options: ProductOption[],
variants: ProductVariant[],
price: {
amount: string,
currencyCode: string,
},
images: {
url: string,
order: number,
}[],
};

type ProductOption = {
id: number,
deletedAt: string,
name: string,
order: number,
values: string,
};

type ProductVariant = {
barcode: string,
deletedAt: string,
id: number,
originId: string,
originalPrice: { amount: string, currencyCode: string },
price: string,
quantity: number,
sku: string,
title: string,
};

Cart types

interface Cart {
cart_id: string;
customer_session_id: string;
shippingCountry: string;
total_amount: number;
currency: string;
available_shipping_countries: string[];
line_items: {
product_id: number,
product_title: string,
supplier: string,
quantity: number,
price_data: {
unit_price: number,
tax: number,
currency: string,
},
variant_id: number | null | undefined,
variant_title: string | null,
variant: {
option: string,
value: string,
}[],
product_available_shippings: {
id: string,
name: string,
description: string,
countryCode: string,
price: {
amount: number,
currencyCode: string,
},
}[],
shipping: {
id: string,
name: string,
description: string,
price: {
amount: number,
currencyCode: string,
},
},
};
}
info
On the cart object:

-available_shipping_countries: Based on the products added to the cart, we check the shipping countries of each product and we return an array with the shipping codes available from the added products shipping classes. This way we narrow the options you can show the final customer to select the cart's shippingCountry.

-shippingCountry: The shipping country assigned to the cart. You can set a default country if you know all your products will be shipped to a specific country. If not, you can use the country codes we provide in the field available_shipping_countries. Based on the value of this field, the available shipping classes on each line item are updated to match with the selected country.

On the cart's line items:

-product_available_shippings: This is an array where you receive all the shipping classes available for the product that matches the country assigned on the shippingCountry field in the cart. This field will return an empty array until you update the cart's shippingCountry.

-shipping:This field will be null until you update the shipping id on the line item. Once you set a shipping class to the line item, the information about the selected shipping class will be displayed here. If this field is null, you won't be able to initiate the payment.

Checkout types

interface Checkout {
id: string;
status: status;
total_price: number;
total_tax: number;
total_line_items_price: number;
total_amount_shipping: number;
deletedAt: string;
success_url: string;
cancel_url: string;
payment_method: string;
email: string;
checkout_url: string;
createdAt: string;
updatedAt: string;
cart: Cart;
availablePaymentMethods: {
name: string,
}[];
shipping_address: Address;
billing_address: Address;
}

interface Address {
id: string;
first_name: string;
last_name: string;
zip: string;
city: string;
phone_code: string;
phone: number;
company: string;
address1: string;
address2: string;
province: string;
province_code: string;
country: string;
country_code: string;
}