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
We want to take a moment to celebrate the incredible ways you all engage with the Shopi...
By JasonH Oct 15, 2024Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024