Skip to content
Advertisement

WooCommerce progress bar from cart contents total value

My aiming result is like this: enter image description here

With the current code its not showing the cart total in the progress bar. What am I doing wrong? And how can I integrate those steps/stacks?

JavaScript
JavaScript
JavaScript

Advertisement

Answer

Your example didn’t state exactly where you wanted this. I’ve added it to the cart page via the woocommerce_before_cart_table action hook. Which would look like this after adding some extra CSS styling.

enter image description here

You could also add this to a template file of course without the add_action/function mark up.

Action hook:

JavaScript

CSS:

JavaScript

The mistake in your example was that you were trying to use PHP to create a value for a JavaScript variable. So to make that work you would either have to jump in and out of PHP:

JavaScript

Or choose to build your whole progress bar in PHP like in my example.

Advertisement