Re: Update product description when cart amount is updated

Update product description when cart amount is updated

WoutervdMeer
Shopify Partner
85 1 15

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)

Dynamic.png

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

Kind regards,
Wouter van der Meer
info@biervaneigenbodem.nl
https://www.biervaneigenbodem.nl/
Reply 1 (1)

Lichen_z
Shopify Partner
59 0 10

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

Co-founder at Freshly Commerce ️ | Building Simple Bundles, Simple Discounts, and Freshly Inventory