Cartflows get cart total without discount

For one of my projects I needed the original cart total price without the Cartflows product discounts. I created the following function to achieve this:

 * Returns total cart price without discounts
function get_cartflows_original_cart_total() {
   return array_reduce( WC()->cart->get_cart(), function( $total, $item ) {
      if ( empty( $item['data'] ) ) return $total;
      $product = $item['data'];
      $regular_price = $product->get_regular_price();
      $item_total = $regular_price * $item['quantity'];
      $total += $item_total;
      return $total;
Robbert Vermeulen

Need help from a WordPress expert?

I would love to hear about your project and how I can help you achieve your goals