Happening now | Office Hours: Customizing Your Theme With Moeed | Ask your questions now!

Display Custom Prices value on Collection Pages

Display Custom Prices value on Collection Pages

ALLAN_Gaubert
Shopify Partner
19 0 2

Hello, For my store, I use the Kaching Bundles app on Shopify to sell items in packs (e.g., a pack of 3 for €39.99, a pack of 6 for €49.99). To display the price for the 3-piece pack on collection and homepage pages, I need to set the price to €39.99 in Shopify, as I sell starting from 3 pieces.

 

Issue:

When customers add a single piece without going through the app bundle, either from the cart or directly from the collection page, it adds €39.99 instead of a unit price for a single piece (for example, €24.99). This means that the 3-piece bundle price is applied to a single item.

 

Need:

I would like to display a unit price ( €24.99) on Shopify, but show the price of the first bundle on collection pages. I want to control which price is visible on these pages while ensuring the correct pricing is applied for individual item additions to the cart.

 

Could someone help me resolve this?

Replies 3 (3)

rajweb
Shopify Partner
827 71 157

Hey @ALLAN_Gaubert ,

you need to achieve two things on your Shopify store:

 

  • Display the 3-piece bundle price (€39.99) on the collection/home pages instead of the individual unit price.
  • Apply the correct unit price (€24.99) when customers add individual items to the cart instead of the bundle price.

Solution Outline:

 

  • Use Shopify product metafields to store the bundle price separately.
  • Modify the product card template to display the bundle price on collection pages.
  • Ensure the correct unit price (€24.99) is applied when the product is added directly to the cart.

Follow these steps:

1. Go to Shopify Admin > Settings > Custom Data > Products.

2. Add a new metafield with:

 

  • Namespace and key: custom.bundle_price
  • Content type: Price
  • In each product’s admin page, set the bundle price (e.g., €39.99) in this metafield.

Edit the Product Card Template

Modify your product card to show the bundle price from the metafield, but ensure the correct unit price applies on add-to-cart.

Follow these steps:

1. Online Store > Themes > Edit Code.

2. Open your product-card.liquid or the equivalent template file used on the collection/home pages.

3. Add the following code inside the price display section:

 

{% assign bundle_price = product.metafields.custom.bundle_price %}

<span class="product-price">
  {% if bundle_price %}
    €{{ bundle_price | money }}
  {% else %}
    {{ product.price | money }}
  {% endif %}
</span>

 

This will show the bundle price (€39.99) if it exists. Otherwise, it defaults to the product’s regular unit price.

 

Ensure Unit Price Applies in Cart

We need to ensure that only the unit price (€24.99) applies when customers add a single item to the cart.

  1. Open product.liquid or the equivalent product template file.
  2. In the Add to Cart button logic, ensure only the base product price is used by adding:

 

<input type="hidden" name="properties[_is_bundle]" value="false">

 

This helps distinguish between single products and bundles in the cart logic.

Modify the Cart Page to Recognize Bundles

f the cart needs to differentiate between bundled and individual items, update the cart template.

  1. Open cart.liquid or cart-items.liquid.
  2. Add logic to ensure bundled items use the correct app pricing and single items use unit prices.
  3. example:

 

{% if item.properties['_is_bundle'] == 'true' %}
  <span class="cart-price">Bundle: {{ item.line_price | money }}</span>
{% else %}
  <span class="cart-price">{{ item.price | money }}</span>
{% endif %}

 

This setup ensures the correct price logic applies based on whether the customer is buying an individual product or a bundle. Let me know if you run into any issues!

thanks

 

 

 

 

Rajat | Shopify Expert Developer
Need a reliable Shopify developer for your next project?
Our App: Productify Groups App
Email: rajat.shopify@gmail.com
Portfolio: https://rajatweb.dev
ALLAN_Gaubert
Shopify Partner
19 0 2

Hello, thank you for your response. I would be happy to try it out, but I don’t see the “Price” option under “Content type.

rajweb
Shopify Partner
827 71 157

Ah, that’s probably because Shopify doesn’t show a price-type metafield by default in all configurations. No worries! We can use a text-type metafield to store the bundle price as a workaround, and we’ll treat it as a price in the code.

Create a Text Metafield:

1. Go to: Shopify Admin > Settings > Custom Data > Products

2. Add a Metafield:

 

  • Namespace and key: custom.bundle_price
  • Content type: Single line text

3. Update Product Card Template

Go to: Online Store > Themes > Actions > Edit Code.

Open: product-card.liquid (or your relevant product listing template).

Replace the price display logic with this code:

 

{% assign bundle_price = product.metafields.custom.bundle_price %}

<span class="product-price">
  {% if bundle_price %}
    €{{ bundle_price }}  <!-- Display bundle price -->
  {% else %}
    {{ product.price | money }}  <!-- Display unit price -->
  {% endif %}
</span>

 

Ensure Unit Price for Single Item Additions:

 

  • Open: product (or your product template).
  • Add this hidden input to ensure the unit price is applied:

 

<input type="hidden" name="properties[_is_bundle]" value="false">  <!-- For single items -->

 

Test Your Changes:

  • On the collection page: Verify that the bundle price (€39.99) shows correctly.
  • Add a single item to the cart: Check that it applies the correct unit price (€24.99).

 

If I was able to help you, please don't forget to Like and mark it as the Solution!

Thanks

 

 

 

Rajat | Shopify Expert Developer
Need a reliable Shopify developer for your next project?
Our App: Productify Groups App
Email: rajat.shopify@gmail.com
Portfolio: https://rajatweb.dev