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

# Fixed Bundles

> Metafields and Metaobject Structure for Fixed Bundles

<Tabs>
  <Tab title="Structure">
    <ResponseField name="fixed_bundle_config" type="Metaobject">
      Fixed Bundle Configuration Metaobject

      <Expandable title="fields" defaultOpen>
        <ResponseField name="bundle_id" type="string" required>
          ID of the bundle within the app
        </ResponseField>

        <ResponseField name="product_properties" type="list of products" required>
          List of product properties containing information about each product in the bundle

          <Expandable title="format">
            <ResponseField name="product_id" type="string" required>
              Product ID (without GID prefix)
              <Note>Example: `12345678`</Note>
            </ResponseField>

            <ResponseField name="quantity" type="number" required>
              Quantity of this product included in the bundle
            </ResponseField>

            <ResponseField name="selected_variant_ids" type="list of variant ids" required>
              List of variant IDs (without GID prefix) selected for this product
              <Note>Example: `["98765432", "98765433"]`</Note>
            </ResponseField>
          </Expandable>
        </ResponseField>

        <ResponseField name="products" type="list of product references" required>
          List of product references included in the bundle
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Tab>

  <Tab title="Liquid Section">
    <Tip>
      Add this snippet as a section in your theme to see the values of the metafield

      **Note**: The `namespace` and `key` are constant for all stores
    </Tip>

    ```liquid theme={null}
    {% liquid
      assign app_namespace = 'app--67872686081'

      assign fixed_bundle_config = product.metafields[app_namespace].fixed_bundle_config.value
      assign bundle_id = fixed_bundle_config.bundle_id.value
      assign product_properties = fixed_bundle_config.product_properties.value
      assign products = fixed_bundle_config.products.value
    %}

    <p><strong>Bundle ID</strong>: {{ bundle_id }}</p>

    <p><strong>Product Properties</strong></p>
    {{ product_properties | json }}

    <p><strong>Products in Bundle:</strong></p>
    {% for product_prop in product_properties %}
      {% assign product_id = product_prop.product_id | times: 1 %}
      {% assign product = products | where: 'id', product_id | first %}
      
      {% if product %}
        <div style="border: 1px solid #ccc; padding: 10px; margin: 10px 0;">
          <p><strong>Product Title:</strong> {{ product.title }}</p>
          <p><strong>Product ID:</strong> {{ product_prop.product_id }}</p>
          <p><strong>Quantity in Bundle:</strong> {{ product_prop.quantity }}</p>
          
          <p><strong>Selected Variants:</strong></p>
          {% for variant_id in product_prop.selected_variant_ids %}
            {% assign var_id = variant_id | times: 1 %}
            {% assign selected_variant = product.variants | where: 'id', var_id | first %}
            
            {% if selected_variant %}
              <div style="margin-left: 20px;">
                <p>- {{ selected_variant.title }} ({{ selected_variant.price | money }})</p>
              </div>
            {% endif %}
          {% endfor %}
        </div>
      {% endif %}
    {% endfor %}

    {% schema %}
    {
      "name": "FoxSell Fixed Bundle Test",
      "settings": [],
      "presets": [
        {
          "name": "FoxSell Fixed Bundle Test"
        }
      ]
    }
    {% endschema %}
    ```
  </Tab>

  <Tab title="FoxSell JS Object">
    <Tip>
      Add this snippet in your `liquid` file to access bundle config via `window.foxsell` object

      **Note**: The `namespace` and `key` are constant for all stores
    </Tip>

    ```liquid theme={null}
    {% liquid
      assign app_namespace = 'app--67872686081'

      assign fixed_bundle_config = product.metafields[app_namespace].fixed_bundle_config.value
      assign bundle_id = fixed_bundle_config.bundle_id.value
      assign product_properties = fixed_bundle_config.product_properties.value
      assign products = fixed_bundle_config.products.value
    %}

    <script>
      window.foxsell = window.foxsell || {};
      window.foxsell.bundleConfig = {
        id: "{{ bundle_id }}",
        products: {{ products | json }},
        productProperties: {{ product_properties | json }}
      }
    </script>
    ```
  </Tab>

  <Tab title="Storefront API">
    <Tip>
      Use the Shopify Storefront API to query the metafields namespace containing your bundle configuration.

      **Note**: The `namespace` and `key` are constant for all stores
    </Tip>

    ```graphql theme={null}
    fragment Product on Product {
      id
      title
      handle
      fixed_bundle_config: metafield(
        namespace: "app--67872686081"
        key: "fixed_bundle_config"
      ) {
        id
        namespace
        key
        value
        type
        reference {
          ... on Metaobject {
            id
            handle
            type
            fields {
              key
              type
              value
              references(first: 30) {
                nodes {
                  ... on Product {
                    id
                    handle
                    title
                    variants(first: 100) {
                      nodes {
                        id
                        title
                        price {
                          amount
                          currencyCode
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
    ```
  </Tab>
</Tabs>
