Help with cart refresh/update in debut theme

Solved
Highlighted
Excursionist
11 0 4

Hello, I have been working on adding some features for out of stock items in my store and added the following code to my cart to show what the items status is (in stock, out of stock, partially in stock) I added it to line 79 right in between price and remove item in my cart-template.liquid section.

{%- comment -%} Cart backorder code {%- endcomment -%}               
                    {% if item.variant.inventory_management == "shopify" and item.variant.inventory_policy == "continue"%}      
                      {% if item.variant.inventory_quantity >= item.quantity %} 
                       {%- comment -%}In stock{%- endcomment -%}
                      {% elsif item.variant.inventory_quantity <= item.quantity and item.variant.inventory_quantity <= 0 %}                  
                        <p> Out of stock - 2-4 week build time. <p>
                      {% elsif item.variant.inventory_quantity <= item.quantity and item.variant.inventory_quantity >= 0 %} 
                        <p> {{ item.variant.inventory_quantity }} in stock - 2-4 week build time on additional quantities.<p>                                                          
                    {% endif %}                  
                    {% endif %}

It works great, except when you start changing the item quantities it does not update without reloading the cart page manually. Any suggestions on how I can get this code to re-run when the quantities change?

I am brand new to working with liquid and shopify themes, so I apologize if I'm missing something obvious.

Thank you!

0 Likes
Highlighted
Shopify Partner
48 4 10

Hey :) 

The reason that it's not updating live is because this code is run right before the page loads and will not run again. You would need some other code (Javascript) to make it update live without refreshing the page.

 

Happy to help you further if you like!

 

Josh

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
1 Like
Highlighted
Excursionist
11 0 4
That’s what I was thinking, just not quite sure how to go about doing it. Any help would be appreciated!
1 Like
Highlighted
Shopify Partner
48 4 10

Any chance I could see your site just to make sure I give you the right info?

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
0 Likes
Highlighted
Excursionist
11 0 4

Here is a preview link, let me know if that's sufficient.

Thank you!

https://iowyxlnpf8wtpgpo-11240833090.shopifypreview.com

 

0 Likes
Highlighted
Shopify Partner
48 4 10

Thanks for sending the link! I can write up a bit of code to make it work for you. Mind if I message you directly so I can ask you a few more questions?

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
0 Likes
Highlighted
Excursionist
11 0 4
Yes, that would be great!
1 Like
Highlighted
Shopify Partner
48 4 10

Great, thanks! I've sent you a message 👍

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
0 Likes
Highlighted
Shopify Expert
9852 98 1617

Going to a direct message doesn't help the community or anyone else that comes across this post later.

if you feel that you _must_ got to a dm, ideally you come back and post the solution you offered. 

★ Winning Partner of the Build a Business competition. ★ http://freakdesign.com.au
2 Likes
Highlighted
Shopify Partner
48 4 10

Thanks Jason,

I plan to post the solution ASAP, just waiting to hear back first.

Joshua Sarros - Freelance Web Developer from Melbourne, Australia
joshuasarros@gmail.com
0 Likes