Add current inventory quantity to "Too many items in cart" message

Add current inventory quantity to "Too many items in cart" message

wwwzeroxcentoit
Shopify Partner
11 0 2

Hello,

let's say a customer wants to buy 10 pillows (but we have only 9 in stock)

he adds them to the cart  but when he clicks on the "add to cart" button he gets an alert saying "You can't add more pillows to the cart" 

 

what we'd like would be add to that message the current available quantity, something like

"Unfortunately we only have xxxcurrentquantityinstockxxx left in stock, send us a message if you want to order more"

 

I've tried to add 

{{ current_variant.inventory_quantity }}

to the translation but it doesn't works, what am I doing wrong?

Thanks for you help

Replies 10 (10)

Tejas_Nadpara
Shopify Partner
1123 222 553

@wwwzeroxcentoit 

 

Ok, I understood your goal. Please send me your store url so I can check and assist you better.

 

Thank you,

Tejas

Shopify Expert | Skype: tejas.nadpara
- Like and Mark as an Accepted Solution if reply helpful
- Feel free to contact me on tejas.nadpara@gmail.com regarding any help
wwwzeroxcentoit
Shopify Partner
11 0 2
www.sanstabu.com

psw woosao

thanks
PageFly-Richard
Shopify Partner
4991 1118 1796

Can you provide product URL to better look at this issue?

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 


All features are available from Free plan. Live Chat Support is available 24/7.

wwwzeroxcentoit
Shopify Partner
11 0 2
https://www.sanstabu.com/products/cushion-love-in-silk-sunlight-red-eros-ludic-sans-tabu

psw woosao

of you add 10 cushions to the cart you"ll see the message i'd like to change

thanks
PageFly-Richard
Shopify Partner
4991 1118 1796

Open file halo.js inside your assets folder of your theme and go to line 2915 change the code to

// Old
$('.ajax-error-message').text($.parseJSON(xhr.responseText).description);

// New
$('.ajax-error-message').text('your_message_that_you_want_to_edit');

Please let me know if it works by giving it a Like or marking it as a solution!


➜ Optimize your Shopify store with PageFly Page Builder (Free plan available) 


All features are available from Free plan. Live Chat Support is available 24/7.

wwwzeroxcentoit
Shopify Partner
11 0 2
Thankyou very much for your help but it's not what I was looking for...

when you get the error message I'd like to show the current available
quantity in stock, something like "you can't add more items to your cart
because we only have xxx in stock" ... xxx should be the current available
quantity in stock

I've tried using {{ current_variant.inventory_quantity }} but it doesn't
works

do you know what's the right variable?

Thanks
ninabayandco
Visitor
1 0 1

Did you ever get a resolution? I'm looking to do the same thing.

esribeiro
Visitor
1 0 1

Hi, did you find out how to do it? I'm looking for the same. Thanks!

Ianthegardenguy
Tourist
6 0 3

Hi!

I would also find this very useful for shopify website as well.  Using debut theme.  Is there any language i can add to  "checkout & system notices" in cart section of theme language or do i need to tweak the code files?

 

Any help would be greatly appreciated.

Ian

Seashore
Excursionist
22 0 54

Hi, i'm looking to do the same thing, did you ever find a solution to this?