Discuss and resolve questions on Liquid, JavaScript, themes, sales channels, and site speed enhancements.
Dear community,
I am currently making technical changes to my website.
For some bundle products I want to dynamically show the amount of products within the bundle they have in their cart, on the product page (the attached).
This amount is a multiplication of the cart quantity and the bundle unit amount. (see code below)
Code:
{% if product.handle contains "bundle" %}
<hr>
{%- assign cart_qty = cart | item_count_for_variant: product.selected_or_first_available_variant.id -%}
<h4>Momenteel bestaat jouw DIY pakket uit (<strong>{{cart_qty}} m2</strong>):
<style><!--
table th, td {padding: 0.3em !important;}
--></style>
<style><!--
table tr:nth-child(odd){background: #F3F3F3; tr:nth-child(even){background: #efefe9;}
--></style>
{% assign current_variant = product.selected_or_first_available_variant %}
{% assign bundled_variants = current_variant.metafields.simple_bundles.bundled_variants.value %}
{% unless bundled_variants == blank %}
<div class="product__description rte">
{% for bundled_variant in bundled_variants %}
<table width="100%">
<tr> <td> <li>
{{ bundled_variant.quantity_in_bundle | times: cart_qty }} x
{{ bundled_variant.product_title }}
{% unless bundled_variant.variant_title == 'Default Title' %}
({{ bundled_variant.variant_title }})
{% endunless %}
</li> </td></tr> </table>
{% endfor %}
</div>
{% endunless %}
</h4>
<hr>
{% endif %}
Everything works properly but the amounts in the table are not updated if the cart amount is updated.
Does someone know how to do/trigger this? I thought this is a javascript thing.
The application for the bundles is 'Simple Bundle'.
Looking forward to the responses.
Kind regards,
Wouter vd Meer
Hi Wouter, I see you've already reached out to us about the customization and are awaiting your reply. Let me know if you'd still like our technical team to look into this. We'd be happy to give it a try!
Lichen
Thanks to everyone who participated in our AMA with 2H Media: Marketing Your Shopify St...
By Jacqui Sep 6, 2024The Hydrogen Visual Editor is now available to merchants in Shopify Editions | Summer '...
By JasonH Sep 2, 2024Note: Customizing your CSS requires some familiarity with CSS and HTML. Before you cust...
By JasonH Aug 12, 2024