From b43dc034e08e290ee549c7c966fde88d08e94554 Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 25 May 2012 16:36:38 +1000 Subject: [PATCH 1/3] Adding order_shipping_to_display & order_subtotal_to_display filters. --- classes/class-wc-order.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/class-wc-order.php b/classes/class-wc-order.php index f2caf04cad3..80b58e5af9e 100644 --- a/classes/class-wc-order.php +++ b/classes/class-wc-order.php @@ -449,7 +449,7 @@ class WC_Order { endif; - return $subtotal; + return apply_filters( 'woocommerce_order_subtotal_to_display', $subtotal, $compound, $this ); } /** Gets shipping (formatted) */ @@ -484,7 +484,7 @@ class WC_Order { $shipping = __('Free!', 'woocommerce'); endif; - return $shipping; + return apply_filters( 'woocommerce_order_shipping_to_display', $shipping, $this ); } /** Get a product (either product or variation) */ From 33acc4c48b048b0287c2a707d30c91e21659dfaa Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 25 May 2012 20:54:52 +1000 Subject: [PATCH 2/3] Adding get_cart_discount_to_display & get_order_discount_to_display filters & functions. --- classes/class-wc-checkout.php | 2 +- classes/class-wc-order.php | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/classes/class-wc-checkout.php b/classes/class-wc-checkout.php index d6ef17c7aee..bbc8ae8cbb9 100644 --- a/classes/class-wc-checkout.php +++ b/classes/class-wc-checkout.php @@ -476,7 +476,7 @@ class WC_Checkout { 'shipping_tax' => number_format($shipping_tax, 2, '.', '') ); } - + error_log( 'storing order_taxes as = ' . print_r( $order_taxes, true ) ); // Save other order meta fields update_post_meta( $order_id, '_shipping_method', $this->posted['shipping_method']); update_post_meta( $order_id, '_payment_method', $this->posted['payment_method']); diff --git a/classes/class-wc-order.php b/classes/class-wc-order.php index 80b58e5af9e..4a3c0b57a67 100644 --- a/classes/class-wc-order.php +++ b/classes/class-wc-order.php @@ -486,6 +486,16 @@ class WC_Order { return apply_filters( 'woocommerce_order_shipping_to_display', $shipping, $this ); } + + /** Get cart discount (formatted) */ + function get_cart_discount_to_display() { + return apply_filters( 'woocommerce_order_cart_discount_to_display', woocommerce_price( $this->get_cart_discount() ), $this ); + } + + /** Get cart discount (formatted) */ + function get_order_discount_to_display() { + return apply_filters( 'woocommerce_order_discount_to_display', woocommerce_price( $this->get_order_discount() ), $this ); + } /** Get a product (either product or variation) */ function get_product_from_item( $item ) { @@ -510,7 +520,7 @@ class WC_Order { $total_rows[ __( 'Cart Subtotal:', 'woocommerce' ) ] = $subtotal; if ( $this->get_cart_discount() > 0 ) - $total_rows[ __( 'Cart Discount:', 'woocommerce' ) ] = '-' . woocommerce_price( $this->get_cart_discount() ); + $total_rows[ __( 'Cart Discount:', 'woocommerce' ) ] = '-' . $this->get_cart_discount_to_display(); if ( $this->get_shipping() > 0 ) $total_rows[ __('Shipping:', 'woocommerce') ] = $this->get_shipping_to_display(); @@ -557,7 +567,7 @@ class WC_Order { } if ( $this->get_order_discount() > 0 ) - $total_rows[ __( 'Order Discount:', 'woocommerce' ) ] = '-' . woocommerce_price( $this->get_order_discount() ); + $total_rows[ __( 'Order Discount:', 'woocommerce' ) ] = '-' . $this->get_order_discount_to_display(); $total_rows[ __( 'Order Total:', 'woocommerce' ) ] = $this->get_formatted_order_total(); From a1b3125258123c5812f8ac3102d4fd6d4434fc0f Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 25 May 2012 21:10:17 +1000 Subject: [PATCH 3/3] Removing error log call that snuck in. --- classes/class-wc-checkout.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wc-checkout.php b/classes/class-wc-checkout.php index bbc8ae8cbb9..4f677caa6de 100644 --- a/classes/class-wc-checkout.php +++ b/classes/class-wc-checkout.php @@ -476,7 +476,7 @@ class WC_Checkout { 'shipping_tax' => number_format($shipping_tax, 2, '.', '') ); } - error_log( 'storing order_taxes as = ' . print_r( $order_taxes, true ) ); + // Save other order meta fields update_post_meta( $order_id, '_shipping_method', $this->posted['shipping_method']); update_post_meta( $order_id, '_payment_method', $this->posted['payment_method']);