> ## Documentation Index
> Fetch the complete documentation index at: https://docs.frenzy.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Overview

> Customizing Product Card for Frenzy Components.

All Frenzy Components (search, collection, recommendation, etc.) use the Product Card. The Product Card can be customized from the Frenzy Shopify Dashboard.

1. Go to **Settings -> Product Grid Widget**.
2. This section contains the HTML structure used to define the Product Card.
3. Developers can customize the Product Card based on the requirements.
4. This HTML structure uses some standard tags to fill in the information like Title, Price, Image, etc. These tags are listed below in [Template variables](#template-variables).
5. The Styling of the Product card and other components is added from `frenzy-css.css` file in theme assets or through **Settings -> Global CSS**.

![Image](https://3137038515-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2F-MCJBp9cjGU5wgbedcI-%2Fuploads%2FpVP6AGMMXo5asQELiCUg%2Fimage.png?alt=media\&token=e98b12c2-e250-4e64-b742-4d564c49aaff)

## Enable the new product cards

The new product cards render each card with React from the same HTML template. They are required for [Swatches](https://docs.frenzy.ai/shopify-app/configuring-product-card/swatches.md), the [Image Swiper](https://docs.frenzy.ai/shopify-app/configuring-product-card/image-swiper.md) and infinite scroll.

```js theme={null}
window.useNewProductCards = true;
```

> [!WARNING]
>
> Without this flag Frenzy uses the old HTML cards. If a store enables infinite scroll without `useNewProductCards`, the grid does not render.

## Where to add the code

All the options on this page and on the [Swatches](https://docs.frenzy.ai/shopify-app/configuring-product-card/swatches.md) and [Image Swiper](https://docs.frenzy.ai/shopify-app/configuring-product-card/image-swiper.md) pages are global variables (`window.*`). Add them in the Frenzy callback file, `assets/frenzy-callback-function.js`, at the top level.

```js assets/frenzy-callback-function.js theme={null}
window.useNewProductCards = true;

window.productCardOptions = {
  type: 'swiper',       // Optional. Turns on the Image Swiper
  swiperOptions: {},   // Optional. See Image Swiper options
  onCardRender: ({ productCardElement, product }) => {} // Optional. Card render hook below
};
```

* `type`: [How to activate the swiper](https://docs.frenzy.ai/shopify-app/configuring-product-card/image-swiper.md#how-to-activate-the-swiper)
* `swiperOptions`: [Image Swiper options](https://docs.frenzy.ai/shopify-app/configuring-product-card/image-swiper.md#options)
* `onCardRender`: [Card render hook](#card-render-hook)

## Template variables

Use these tags in the Product Card HTML. Frenzy replaces them with the product data.

| Variable | Value |
| - | - |
| `[[id]]` | Product ID |
| `[[product_id]]` | Product SKU (`productId_variantId`) |
| `[[product_title]]` | Product title |
| `[[product_title_split_1]]`, `[[product_title_split_2]]` | Title split in two parts |
| `[[product_url]]`, `[[url]]` | Product URL |
| `[[product_handle]]` | Product handle |
| `[[product_type]]`, `[[product_brand]]` | Product type and vendor |
| `[[product_featured_image]]` | Main image |
| `[[product_second_image]]` | Second image |
| `[[product_sale_price]]`, `[[product_compare_price]]` | Formatted prices |
| `[[product_tags]]` | Product tags |
| `[[product_options]]` | Variant options and add to cart button |
| `[[product_sale_tag]]`, `[[product_stock_out_tag]]` | Marker classes for the sale and sold out tags |
| `[[product_add_to_cart]]`, `[[product_quickview]]` | Marker classes for add to cart and quick view |

## Card behavior

* **Secondary image on hover** (`grid_show_secondary_image = "1"`): only works on desktop, and it is turned off when the [Image Swiper](https://docs.frenzy.ai/shopify-app/configuring-product-card/image-swiper.md) is active.
* **Extra first image**: `window.frenzyImageKeyName` puts an image from a product field first in the image list. Only on cards without swatches.
* **Add to cart** follows the Frenzy settings (`product_option_type`, `stop_direct_add_to_cart_button`). If no variant is selected, the first variant with stock is used. When the card has swatches, the selected swatch's variant is used.

## Card render hook

`window.productCardOptions.onCardRender` is called once per card after it mounts. It receives `productCardElement`, `product`, `productId`, `sku`, `classType`, `swatches`, `selectedSwatch` and `selectedSwatchIndex`. Stores can use it to patch the card DOM without touching the bundle.

### Example: add the product type as a data attribute

```js theme={null}
window.useNewProductCards = true;

// Optional: changes on each card after it renders
window.productCardOptions = {
  onCardRender: ({ productCardElement, product }) => {
    productCardElement.dataset.productType = product.org_product_type;
  }
};
```

### Example: add a badge to cards with a product tag

```js theme={null}
window.productCardOptions = {
  onCardRender: ({ productCardElement, product }) => {
    // org_product_tags can be an array or a comma separated string
    const tags = Array.isArray(product.org_product_tags)
      ? product.org_product_tags
      : String(product.org_product_tags || '').split(',').map((tag) => tag.trim());
    if (!tags.includes('new-arrival')) return;

    const image = productCardElement.querySelector('.frenzy_img_first')?.parentElement;
    if (!image || image.querySelector('.badge-new')) return;
    image.insertAdjacentHTML('beforeend', '<span class="badge-new">New</span>');
  }
};
```

> [!NOTE]
>
> If `window.productCardOptions` already exists in the `assets/frenzy-callback-function.js`, add 'onCardRenderer' to that object instead of creating a new one. Assigning a new object replaces the swiper settings.
>
> ```js theme={null}
> // Correct: add the hook to the existing object
> window.productCardOptions = {
>   type: 'swiper',
>   swiperOptions: {
>     mobileOnly: true,
>     loop: false
>   },
>   onCardRender: ({ productCardElement, product }) => {
>     productCardElement.dataset.productType = product.org_product_type;
>   }
> };
>
> // Wrong: a second object later in the file replaces the one above and turns off the swiper
> window.productCardOptions = {
>   onCardRender: ({ productCardElement, product }) => { /* ... */ }
> };
> ```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.