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

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

1 Like

@wwwzeroxcentoit

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

Thank you,

Tejas

www.sanstabu.com

psw woosao

thanks

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

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

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');

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

1 Like

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

1 Like

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

2 Likes

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

1 Like

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