> For the complete documentation index, see [llms.txt](https://help.pixfizz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://help.pixfizz.com/ecommerce/shopify-+-pixfizz/adapting-the-pixfizz-cart-integration-to-non-dawn-shopify-themes.md).

# Adapting the Pixfizz cart integration to non-Dawn Shopify themes

The Pixfizz Shopify cart integration is documented and tested against the Dawn theme. This article explains what the cart hooks do and how to place them correctly in any other theme, so personalized line items show a live preview, can be re-opened in the design tool, and keep their add-on lines in sync.

***

### Overview

In a Shopify and Pixfizz store, the cart still belongs to your Shopify theme. Pixfizz adds a small set of hooks to the cart so that personalized items behave correctly. There are five Pixfizz snippets in total. Three of them live on the cart line item:

* `pixfizz-orderline-preview-handler` swaps the static product image for a live preview of the customer's project.
* `pixfizz-edit-orderline-handler` lets the customer re-open their project in the design tool from the cart.
* `pixfizz-orderline-quantity-handler` keeps add-on lines (such as extra book pages) in step when the quantity changes or the item is removed.

The other two, `pixfizz-setup` and `pixfizz-launch-product-handler`, live in the theme head and on the product page. They are covered in the main Shopify integration article and are assumed to be in place already.

Every theme renders its cart differently. The hooks themselves do not change, only the elements you attach them to. This article gives you a method for finding those elements in your theme.

### Before you start

Confirm the following, or the cart hooks will have nothing to work with:

* `pixfizz-setup` is rendered in `theme.liquid` inside the `<head>`.
* The five `pixfizz-*` snippets exist in the theme.
* Personalized products are linked correctly with their Pixfizz metafields, so cart items carry the `_pixfizz_project_id` property.

Always work on a duplicate of your theme and preview the changes before publishing. Test add to cart, the cart preview, re-opening the design tool, a quantity change, and a remove, before the theme goes live.

### The cart hooks and where they attach

| Hook                        | What it does                                                                 | Where it attaches                                    |
| --------------------------- | ---------------------------------------------------------------------------- | ---------------------------------------------------- |
| Add-on skip                 | Stops add-on lines rendering as their own full row                           | The very top of the `for item in cart.items` loop    |
| Preview handler             | Replaces the static image with the live project preview                      | Immediately after the line item `<img>`              |
| Edit handler                | Re-opens the project in the design tool                                      | The link around the image, or the product title link |
| Quantity lock               | Shows a fixed quantity for products where the quantity is set inside Pixfizz | Around the quantity control                          |
| Quantity and delete handler | Keeps add-on lines in sync on change and removal                             | The quantity `<input>` and the remove control        |
| Add-on sub-rows             | Shows add-on lines as a display-only row under their parent                  | After the parent line item row                       |

The preview handler is safe to include for every item. It only acts when `_pixfizz_project_id` is present, so non-personalized products are untouched.

### How to adapt the cart to your theme

Open your theme's cart template, find the part that loops over the cart items, then work through the elements in order.

1. **Find the line item loop.** Look for `{% for item in cart.items %}` (the variable may be named `line_item`). Put the add-on skip at the very top, before the row markup opens:

   ```liquid
   {%- if item.properties._pixfizz_addon -%}
     {% continue %}
   {%- endif %}
   ```
2. **Find the line item image.** Place the preview handler immediately after the `<img>` tag, inside the same container:

   ```liquid
   {% render 'pixfizz-orderline-preview-handler', item: item, width: 600 %}
   ```

   Use a `width` of roughly twice the displayed size. A small value gives a blurry, upscaled thumbnail. About `600` suits a typical cart image.
3. **Find the image or title link.** Add the edit handler to whichever element the customer clicks to open the item. Only add it when the item is a Pixfizz project:

   ```liquid
   {%- if item.properties._pixfizz_project_id -%}
     onclick="{% render 'pixfizz-edit-orderline-handler', item: item %}"
   {%- endif -%}
   ```

   If a layer sits above the link and swallows the click, give the link `style="z-index:1;"` so the click reaches it.
4. **Find the quantity control.** Add the change handler to the quantity `<input>`, again only for Pixfizz items:

   ```liquid
   {%- if item.properties._pixfizz_project_id -%}
     onchange="{% render 'pixfizz-orderline-quantity-handler', item: item, cart: cart %}"
     onkeydown="if(event.keyCode===13)event.preventDefault()"
   {%- endif -%}
   ```

   For products where the quantity is set inside Pixfizz (photo prints), wrap the quantity control so it shows a fixed number instead:

   ```liquid
   {%- if item.product.metafields.pixfizz.adjust_cart_qty.value == false -%}
     <span>{{ item.quantity }}</span>
   {%- else -%}
     ... the theme's normal quantity control ...
   {%- endif -%}
   ```

   The metafield is a real boolean, so the check is `== false`, not the text `"false"`.
5. **Find the remove control.** Add the delete handler to the remove link:

   ```liquid
   {%- if item.properties._pixfizz_project_id -%}
     onclick="{% render 'pixfizz-orderline-quantity-handler', item: item, cart: cart, delete_item: true %}"
   {%- endif -%}
   ```
6. **Add the add-on sub-rows.** After the parent item row, render its add-ons as a display-only row:

   ```liquid
   {%- if item.properties._pixfizz_project_id -%}
     {%- for addon_item in cart.items -%}
       {%- if addon_item.properties._pixfizz_addon == item.properties._pixfizz_project_id -%}
         ... a simple row: title, quantity, line price, no controls ...
       {%- endif -%}
     {%- endfor -%}
   {%- endif -%}
   ```
7. **Repeat for the drawer cart.** If the theme has a drawer or mini-cart, the same quantity and remove controls live there too. The handlers must be added in both places, or quantities and removals will fall out of sync in whichever one you miss.

### How it works

#### Why the preview survives cart updates

The preview handler uses a `style onload` technique so it re-runs every time the cart re-renders, including after an AJAX quantity change. If you ever see the preview work once and then revert to the static image after a change, check that the handler has not been wrapped inside a `<script>` tag, which would stop it re-running.

#### Why add-ons need the quantity handler

Some products add extra Pixfizz lines to the cart, such as extra pages on a photo book. Those add-on lines must move with their parent. When the parent quantity changes the handler updates the add-on quantities to match, and when the parent is removed the handler removes the add-ons too. This is why the handler has to be on every quantity and remove control across the theme.

### Theme-specific notes

#### Dawn

Dawn is the reference implementation. The cart is a table of rows, the image sits in a container with the class `cart-item__image-container`, the quantity is an inline input inside a `quantity-input` element, and the remove control is a link inside `cart-remove-button`. All the hooks attach inline as described above.

#### Maestrooo themes (Focal family)

These themes structure the cart differently and need two adjustments:

* The image sits inside an `aspect-ratio` wrapper whose own image rule uses absolute positioning, which can hide the swapped-in preview. Add a small CSS override scoped under the line item image wrapper to restore it.
* If the theme adds third-party app code to the cart, such as a product options app, leave those lines in place. They are required for that app to work.

#### Newer component-based themes

Some recent themes render the cart through web components and shared snippets rather than inline markup. In these themes:

* The preview handler and the quantity lock still work, because they attach to the image and to the quantity area in the cart template.
* The quantity change handler and the remove handler may not, because the quantity input comes from a shared snippet and the remove action is wired through the theme's own event system rather than a plain link. In that case the add-on sync hooks cannot be added with the inline method and need development work at the JavaScript level. If your theme works this way, contact your Pixfizz account manager before changing the cart.

### Tips

* Include the preview handler for every line item. It checks for a Pixfizz project itself and ignores everything else.
* Keep the start and end of each change clearly marked with comments. It makes the next theme update far easier to apply and review.
* Test the drawer cart and any quick-add control as well as the main cart page. Missing handlers there are the most common cause of add-on lines drifting out of sync.

### Summary

| Symptom                                           | Likely cause                                                                     |
| ------------------------------------------------- | -------------------------------------------------------------------------------- |
| Preview not showing                               | Handler not directly after the `<img>`, or the item has no `_pixfizz_project_id` |
| Preview reverts after a quantity change           | Handler placed inside a `<script>` tag                                           |
| Edit click does nothing                           | A layer above the link is catching the click, add `z-index:1`                    |
| Add-on quantities do not follow the parent        | Quantity handler missing on a quantity control, often in the drawer cart         |
| Quantity selector shows on a photo-prints product | The `adjust_cart_qty` metafield is missing or set to text instead of a boolean   |

### Related

* Shopify integration: setup, metafields, and the Dawn cart
* Add-on products: extra pages and option add-ons
