Cart - AquilaCMS/aquila-connector GitHub Wiki

/src/api/cart/index.js

Functions

Get a specific cart

getCart(cartId, lang)
  • cartId - string : id of the cart
  • postBody - any? : request body overload - Optional
  • lang - string? : current language ("fr" is the default value) - Optional
Example
import { getCart } from 'aquila-connector/api/cart';
const cart = await getCart("123abc456");

Add product into cart

addToCart(cartId, product, qty, selections, params)
  • cartId - id : ID of cart
  • product - any : Product
  • qty - int : Quantity of product to apply
  • selections - any? : Only for "bundle" type products, contains the products that compose the bundle - Optional
  • params - any? : Additional request parameters - Optional
Example
import { addToCart } from 'aquila-connector/api/cart';
const newCart = await addToCart("123abc456", product, 1, selections);

Remove a product from the cart

deleteItem(cartId, itemID)
  • cartId - id : ID of cart
  • itemID - id : Product ID in cart
Example
import { deleteItem } from 'aquila-connector/api/cart';
const newCart = await deleteItem("123abc456", itemId);

Updates the quantity of a product in the cart

updateQtyItem(cartId, itemId, quantity)
  • cartId - id : ID of cart
  • itemId- id : Product ID in cart
  • quantity - int : Quantity of product to apply
Example
import { updateQtyItem } from 'aquila-connector/api/cart';
const newCart = await updateQtyItem("123abc456", itemId, quantity);

Add discount to cart

addDiscount(cartId, discount)
  • cartId - id : ID of cart
  • discount - string : Discount code
Example
import { addDiscount } from 'aquila-connector/api/cart';
const newCart = await addDiscount("123abc456", 'DISCOUNT15);

Delete discount from cart

deleteDiscount(cartId)
  • cartId - id : ID of cart
Example
import { deleteDiscount } from 'aquila-connector/api/cart';
const newCart = await deleteDiscount("123abc456");

Assign user addresses to cart

setCartAddresses(cartId, addresses)
  • cartId - id : ID of cart
  • addresses - any : Object containing the billing and delivery address
Example
import { setCartAddresses } from 'aquila-connector/api/cart';
const newCart = await setCartAddresses("123abc456", adresses);

Get shipment methods from cart

getShipmentCart(cart, withCountry, PostBody, lang)
  • cart - any : Cart object
  • withCountry - boolean - Optional
  • PostBody - any? : request body overload - Optional
  • lang - string? : current language ("fr" is the default value) - Optional
Example
import { getShipmentCart } from 'aquila-connector/api/cart';
const shipments = await getShipmentCart("123abc456");

Set selected shipment method in cart

setCartShipment(cartId, shipment, isoCountryCode, lang)
  • cartId - any : ID of cart
  • shipment - any - Shipment object
  • isoCountryCode - string : Country code of delivery address
  • lang - string? : current language ("fr" is the default value) - Optional
Example
import { getShipmentCart } from 'aquila-connector/api/cart';
const shipments = await getShipmentCart("123abc456", shipment, 'FR');

Delete shipment method from cart

deleteCartShipment(cartId)
  • cartId - any : ID of cart
Example
import { deleteCartShipment } from 'aquila-connector/api/cart';
const shipments = await deleteCartShipment("123abc456");

Convert a cart into an order

cartToOrder(cartId, lang)
  • cartId - id : ID of cart
  • lang - string? : current language ("fr" is the default value) - Optional
Example
import { cartToOrder } from 'aquila-connector/api/cart';
const order = await cartToOrder(cartId, 'fr');
⚠️ **GitHub.com Fallback** ⚠️