Problem with subtotal and shipping estimator in cart drawer

Topic summary

A user is experiencing issues with a custom shipping cost estimator in their Shopify cart drawer on neosino.at.

The Problem:

  • They want to remove the separate subtotal section and display only the subtotal amount inside the “Shop Now” button
  • The button frequently shows “Estimating shipping” (“Berechne Versand…” in German) instead of the actual subtotal
  • This occurs especially in fresh sessions (incognito mode) and when the cart updates dynamically

Technical Details:

  • Custom JavaScript has been added to cart-drawer.liquid but isn’t connecting properly to the button
  • The subtotal should display immediately when items are added to cart
  • User provided a screenshot showing the desired final appearance and referenced esn.com as inspiration

Status: The issue remains unresolved with no responses yet. The user is seeking help to ensure the subtotal always displays as a number in the button, eliminating the “Estimating shipping” placeholder text.

Summarized with AI on October 29. AI used: claude-sonnet-4-5-20250929.

On neosino.at I have successfully built in the shipping cost estimator bar, but I have a problem.

I want to delete the subtotal section completely and only have the subtotal amount displayed inside the “Shop Now” button.

In my cart-drawer.liquid, I have already added some JavaScript, but I can’t figure out how to connect it properly to the “Shop Now” button. Most of the time, the button shows “Estimating shipping” instead of the actual subtotal amount, and I want to avoid that.

It should always display the correct number (the subtotal) as soon as there’s something in the cart.

When I open the store in an incognito tab and add something to the cart, it still says “Estimating shipping” - in German: Berechne Versand…, so it’s not displaying the right value.

Does anyone know how to make the subtotal always appear as a number inside the button, even on a fresh session or when the cart drawer updates dynamically?

In the end, it should always look like this, so no Estimating shipping” - in German: Berechne Versand…

my inspo: https://www.esn.com/

Cart drawer code can be a different file/location than cart page code.
Or there is an initial template that needs to be customized
You’d just update the buttons contents using your custom javascript.
If your referring to using buy-buttons/accelerated-checkout buttons those may render dynamically AFTER the page loads.

I can hear that your button text is being updated ahead of the cart.js or the cart drawer state, but it has not yet received the cart subtotal yet, that is why it is still displaying and not yet the actual number of what it is going to cost you to have.

The AJAX cart or drawer system in Shopify requires you to re-render the subtotal within your JavaScript function (generally), not only on loading the page. Try something like:

fetch(‘/cart.js’)
.then(res => res.json())
.then(cart => {
const subtotal = (cart.total_price / 100).toFixed(2);
document.querySelector(‘.shop-now-btn’).textContent = Shop Now • €${subtotal};
});

I can look briefly at your cart-drawer.liquid and JS structure to demonstrate where to get this connected-in without disruption of the current shipping estimator. At other times it is merely a case of placing one line or putting the listener in the appropriate position.

I’ve tried to fix it but honestly, I don’t really have an idea of the problem. Would it be possible for you to access the shop and look at the code itself?

I understand you are facing challenges of not having idea of the solution, Yes its possible for me to help you.

thank you, do you need the permission in my shop?

Hey @Neosino,

For sure we can fix it for you.

Would you like to share the collab code in the p/m so that I can take a look and fix it.

Thanks

Yes i sent you a direct text so you don’t share you info in public.

Hi Paul, I wanted to kindly ask if you could get access to my shop and fix it in the code, because I can’t seem to fix it myself. It would be very much appreciated.

Hi @Neosino

That’s because your button text changes before Shopify finishes retrieving the cart information. To fix this, just ensure your Javascript waits until the cart object is loaded before reading then reads cart.total_price every time your drawer refreshes.

In your cart-drawer.js, something along the lines of the following:

function updateCartButton() {

fetch(‘/cart.js’)

.then(res => res.json())

.then(cart => {

const total = (cart.total_price / 100).toFixed(2) + ’ €’;

document.querySelector(‘.shop-now-button’).textContent = total;

});

}

document.addEventListener(‘cart:updated’, updateCartButton);

document.addEventListener(‘DOMContentLoaded’, updateCartButton);

That makes sure that the subtotal shows up right away, even in a new session or after any cart modification.

I can’t find that in my code and for some reason can’t post the code

If you need services then click my profile pick for options to connect.
ALWAYS provide context in new communications.