Themes built on the Twig templating engine are now deprecated and require migration to Vitrin to ensure continued support and compatibility with Zid.
This page documents the new Vitrin cart functions and, under each item, shows the old Zid function it replaces.
window.vitrin.cart
.vitrin.cart.get()
zid.store.cart.fetch()
vitrin.cart.addProduct(payload)
zid.store.cart.addProduct({ productId, quantity, ... })
product_id
(required) — Product identifier.quantity
(required) — Number of units (> 0).custom_fields
(optional) — Array of selected customizations (only send if the product has options like size, color, add-ons, or extra inputs).custom_fields
parameter allows you to send product customizations (e.g., size, color, engraving text, file uploads) to the backend. It is an optional array, and each entry represents one selected option or filled input.{
price_settings: string | null; // unique ID linking the choice to backend pricing/variants
group_name: string | null; // label of the group (e.g., "Color", "Add-ons")
group_id: string | null; // unique group identifier
name: string | null; // field/option label or name
value: string | null; // user’s input or selected option
type: 'CHECKBOX' | 'DROPDOWN' | 'TEXT' | 'NUMBER' | 'FILE' | 'IMAGE' | 'TEXTAREA';
}
Note: custom_fields
are optional. Only include them if the product has custom options.
{
"price_settings": "5dd00588-2d18-4613-a991-3e23522b1052",
"group_name": "Extras",
"group_id": "4fba4318-e399-4343-ba5f-e70728b419c5",
"name": "Gift Wrap",
"value": "✔",
"type": "CHECKBOX"
}
{
"price_settings": "64c73acb-9d8f-4f1c-afdb-a175bf50ac53",
"group_name": "Color",
"group_id": "bc9b1ba1-3b83-4edd-bb36-1dbf9ca9aaac",
"name": "Red",
"value": "✔",
"type": "DROPDOWN"
}
custom_fields
price_settings
IDs to apply extra charges (e.g., engraving +120 SAR, image upload +150 SAR, color red +234 SAR → total +504 SAR).Key Point: price_settings
is the unique identifier that connects each customization in the cart to backend pricing and inventory logic.
vitrin.cart.updateProduct({ id, quantity })
zid.store.cart.updateProduct(cart_product_id, quantity, product_id)
id
field from cart_response.products[index].id
.
vitrin.cart.removeProduct({ id })
zid.store.cart.removeProduct(cart_product_id, product_id)
cart_response.products[index].id
).
vitrin.cart.applyCoupon({ coupon_code })
zid.store.cart.redeemCoupon(coupon_code)
vitrin.cart.removeCoupons()
zid.store.cart.removeCoupon()
vitrin.cart.empty()
– remove all items (keep cart session)vitrin.cart.remove()
– delete cart session entirelyzid.store.cart.removeProducts(with_cart_delete)
id
(cart product id) replaces cart_product_id
for update/remove operations.redeemCoupon
→ applyCoupon
and removeCoupon
→ removeCoupons
.empty()
vs remove()
for different clearing behaviors.For product/variant selection rules and complex products, see the Products page.