Features/Integrations

Shopify cart and checkout

A client-side cart with add, quantity and remove buttons that hands off to Shopify checkout.

Mark buttons and elements with Shopify roles to build a cart: add to cart, increase, decrease, remove, cart count, subtotal and an item list made from your own item template. Checkout sends the cart lines to Divhunt, which creates a Shopify cart with the Storefront API and redirects the visitor to Shopify's secure checkout.

How it works

  • Events shopify:cart:updated, shopify:cart:added.
  • Add to cart: [shopify-cart="add"] with shopify-variant-id (required), shopify-product-title, -handle, -image, shopify-variant-title, shopify-product-price, shopify-product-currency, shopify-quantity. Button shows 'Added!' for 1.5 s.
  • Cart page: [shopify-cart] items, item-template, empty, subtotal; per item image, title, variant, price, quantity (editable), total; increase/decrease/remove buttons. Prices formatted with Intl.NumberFormat.
  • Cart count gets class 'empty' at 0.
  • Cart is cleared when the visitor returns from a checkout referrer.

When to use it

  • Add to cart on product cards
  • A full cart page designed in Divhunt

Limitations

  • Max 50 lines and quantity 99 per line; the client does not cap quantity, so above 99 checkout fails with 'Invalid cart.'
  • Prices in the cart come from element attributes, Shopify recalculates at checkout
  • Cart is per browser (localStorage), not synced across devices
  • Cart clears on return from checkout even if the order was not paid

Availability

  • Works in Designer.
  • Included in every plan.
  • Limits: 50 lines, quantity 1-99

How to use it.

  1. Select a button, Shopify panel > Action > Add to Cart
  2. Fill Variant ID and other fields with product variables
  3. Build a cart section with Items Container and Item Template
  4. Add a Checkout button

Related features.

No card needed

Build it today.Pay when it goes live.

Every feature is unmetered while you build. Checkout opens the first time you publish.