From 0b49818a5e4c1f82f7c342fabbd7702b5188f05a Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 27 Apr 2012 12:18:18 +1000 Subject: [PATCH 1/5] Adding "woocommerce_order_formatted_line_subtotal" filter to get_formatted_line_subtotal function. Adding new WC_Order::get_formatted_order_total() to centralise order total formatting and provide a new filter for order total. Replacing all instances of "woocommerce_price($order->order_total)" with new WC_Order::get_formatted_order_total() function. --- classes/class-wc-order.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/classes/class-wc-order.php b/classes/class-wc-order.php index 1728cccfc2b..03e6f23a773 100644 --- a/classes/class-wc-order.php +++ b/classes/class-wc-order.php @@ -377,7 +377,16 @@ class WC_Order { else : $subtotal = woocommerce_price( $this->get_line_subtotal( $item, true ) ); endif; - return $subtotal; + + return apply_filters( 'woocommerce_order_formatted_line_subtotal', $subtotal, $item, $this ); + } + + /** Gets order total - formatted for display */ + function get_formatted_order_total() { + + $fomatted_total = woocommerce_price( $this->order_total ); + + return apply_filters( 'woocommerce_get_formatted_order_total', $formatted_total, $this ); } /** Gets subtotal - subtotal is shown before discounts, but with localised taxes */ From 6df9fff54d6be3d4bf106361b8eff769ff2db0e1 Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 27 Apr 2012 12:22:19 +1000 Subject: [PATCH 2/5] Adding "Replacing instances of "woocommerce_price($order->order_total)" with new WC_Order::get_formatted_order_total() function. --- admin/post-types/shop_order.php | 2 +- shortcodes/shortcode-pay.php | 2 +- templates/checkout/thankyou.php | 2 +- templates/myaccount/my-orders.php | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/admin/post-types/shop_order.php b/admin/post-types/shop_order.php index cb5d12ec0ef..f3274edc48a 100644 --- a/admin/post-types/shop_order.php +++ b/admin/post-types/shop_order.php @@ -113,7 +113,7 @@ function woocommerce_custom_order_columns($column) { endif; break; case "total_cost" : - echo woocommerce_price($order->order_total); + echo $order->get_formatted_order_total(); break; case "order_date" : diff --git a/shortcodes/shortcode-pay.php b/shortcodes/shortcode-pay.php index d65f796f660..ff91eff972a 100644 --- a/shortcodes/shortcode-pay.php +++ b/shortcodes/shortcode-pay.php @@ -79,7 +79,7 @@ function woocommerce_pay() {
  • - order_total); ?> + get_formatted_order_total(); ?>
  • payment_method_title) : ?>
  • diff --git a/templates/checkout/thankyou.php b/templates/checkout/thankyou.php index 791a0f7a517..617060a0db9 100644 --- a/templates/checkout/thankyou.php +++ b/templates/checkout/thankyou.php @@ -42,7 +42,7 @@ global $woocommerce;
  • - order_total); ?> + get_formatted_order_total(); ?>
  • payment_method_title) : ?>
  • diff --git a/templates/myaccount/my-orders.php b/templates/myaccount/my-orders.php index 99ae8e368d3..699b45577c0 100644 --- a/templates/myaccount/my-orders.php +++ b/templates/myaccount/my-orders.php @@ -44,7 +44,7 @@ if ($customer_orders) : get_order_number(); ?>
    get_formatted_shipping_address()) echo $order->get_formatted_shipping_address(); else echo '–'; ?>
    - order_total); ?> + get_formatted_order_total(); ?> name, 'woocommerce' ) ); ?> status, array('pending', 'failed'))) : ?> From a75902d292a4b2469a517d8397f01c8961affc78 Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 27 Apr 2012 12:27:37 +1000 Subject: [PATCH 3/5] Ugh variable name typo, teach me to commit/push before testing - sorry! --- classes/class-wc-order.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wc-order.php b/classes/class-wc-order.php index 03e6f23a773..e090648a979 100644 --- a/classes/class-wc-order.php +++ b/classes/class-wc-order.php @@ -384,7 +384,7 @@ class WC_Order { /** Gets order total - formatted for display */ function get_formatted_order_total() { - $fomatted_total = woocommerce_price( $this->order_total ); + $formatted_total = woocommerce_price( $this->order_total ); return apply_filters( 'woocommerce_get_formatted_order_total', $formatted_total, $this ); } From 1f8409ad0be7da87c4cf12e5cdbff97c44d524f8 Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 27 Apr 2012 12:38:06 +1000 Subject: [PATCH 4/5] Updating instance of woocommerce_price( $this->get_order_total() ) to use new get_formatted_order_total() function. --- classes/class-wc-order.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/classes/class-wc-order.php b/classes/class-wc-order.php index e090648a979..3fa563877ae 100644 --- a/classes/class-wc-order.php +++ b/classes/class-wc-order.php @@ -551,7 +551,7 @@ class WC_Order { if ( $this->get_order_discount() > 0 ) $total_rows[ __( 'Order Discount:', 'woocommerce' ) ] = '-' . woocommerce_price( $this->get_order_discount() ); - $total_rows[ __( 'Order Total:', 'woocommerce' ) ] = woocommerce_price( $this->get_order_total() ); + $total_rows[ __( 'Order Total:', 'woocommerce' ) ] = $this->get_formatted_order_total(); return apply_filters( 'woocommerce_get_order_item_totals', $total_rows, $this ); } From 0e34d66ac1defbc5bc4fde0dac494f01cf8df011 Mon Sep 17 00:00:00 2001 From: Brent Shepherd Date: Fri, 27 Apr 2012 17:00:47 +1000 Subject: [PATCH 5/5] Replacing formatting code duplicated in email items template with call to WC_Order::get_formatted_line_subtotal(). --- templates/emails/email-order-items.php | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/templates/emails/email-order-items.php b/templates/emails/email-order-items.php index e07d9dab7ab..b65cbc52331 100644 --- a/templates/emails/email-order-items.php +++ b/templates/emails/email-order-items.php @@ -35,18 +35,7 @@ foreach ($items as $item) : ?> - display_cart_ex_tax || !$order->prices_include_tax ) : - $ex_tax_label = ( $order->prices_include_tax ) ? 1 : 0; - echo woocommerce_price( $order->get_line_subtotal( $item ), array('ex_tax_label' => $ex_tax_label )); - else : - echo woocommerce_price( $order->get_line_subtotal( $item, true ) ); - endif; - - ?> - + get_formatted_line_subtotal( $item ); ?> id, '_purchase_note', true)) : ?>