Title: Get cart total programmatically
Last modified: June 16, 2020

---

# Get cart total programmatically

 *  Resolved [simaooliveira](https://wordpress.org/support/users/simaooliveira/)
 * (@simaooliveira)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/get-cart-total-programmatically/)
 * Hi! I’m using your plugin to do a quantity based discount. I want to pull the
   cart total, with the discount already applied, to a side script that generates
   legal documents. How can I go about doint this ? I’ve inspected WC()->cart to
   try to find the amounts of the discounts, or an already discounted value, but
   to no avail, and WC()->cart->get_cart_total() gives me the non discounted value.
 * Is there a function or filter i should run?
 * Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)

 *  Plugin Author [Hermann LAHAMI](https://wordpress.org/support/users/mano88/)
 * (@mano88)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/get-cart-total-programmatically/#post-12993864)
 * I’m sorry we don’t store any calculated data. I tried with wc_cart_totals_subtotal_html()
   and WC()->cart->get_cart_total() from a shortcode I wrote and it worked fine.
   I’m able to pull the subtotal including the discounts for items with bulk discounts
   added to the cart.
 * I’m not sure which part is failing on your side…
 *  Thread Starter [simaooliveira](https://wordpress.org/support/users/simaooliveira/)
 * (@simaooliveira)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/get-cart-total-programmatically/#post-12996560)
 * Tried doing wc_cart_totals_subtotal_html() on a template and i get the undiscounted
   amount as well…
 *  Plugin Author [Hermann LAHAMI](https://wordpress.org/support/users/mano88/)
 * (@mano88)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/get-cart-total-programmatically/#post-12996606)
 * Are you sure your code is being exectued after woocommerce calculated the totals?
 *  Thread Starter [simaooliveira](https://wordpress.org/support/users/simaooliveira/)
 * (@simaooliveira)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/get-cart-total-programmatically/#post-12996668)
 * You’re right, that was the issue. I did WC()->cart->calculate_totals(); and now
   i get the discounts available on the WC()->cart object. Thank you so much for
   your help!
 *  Plugin Author [Hermann LAHAMI](https://wordpress.org/support/users/mano88/)
 * (@mano88)
 * [5 years, 11 months ago](https://wordpress.org/support/topic/get-cart-total-programmatically/#post-12996720)
 * My pleasure.

Viewing 5 replies - 1 through 5 (of 5 total)

The topic ‘Get cart total programmatically’ is closed to new replies.

 * ![](https://ps.w.org/woo-advanced-discounts/assets/icon-256x256.png?rev=1857281)
 * [Conditional Discounts for WooCommerce - A simple yet complete woocommerce dynamic pricing plugin](https://wordpress.org/plugins/woo-advanced-discounts/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/woo-advanced-discounts/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/woo-advanced-discounts/)
 * [Active Topics](https://wordpress.org/support/plugin/woo-advanced-discounts/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/woo-advanced-discounts/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/woo-advanced-discounts/reviews/)

 * 5 replies
 * 2 participants
 * Last reply from: [Hermann LAHAMI](https://wordpress.org/support/users/mano88/)
 * Last activity: [5 years, 11 months ago](https://wordpress.org/support/topic/get-cart-total-programmatically/#post-12996720)
 * Status: resolved