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;

I'm Robbert Vermeulen. I document everything I learn and help thousands of people with coding WordPress. My site has no ads or sponsors. If you enjoy my content, please consider supporting what I do.


    No comments yet..

Leave a reply

Feel free to ask questions or make comments.