Pass instance of WC_Order to its filters
So that extensions hooking to the filters know which order the current filter is being applied to and can perform customisation on specific orders (not just all orders). Conflicts: includes/class-wc-order.php
This commit is contained in:
parent
345ae3248f
commit
f9a42a497d
|
@ -407,7 +407,7 @@ class WC_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_total_tax() {
|
||||
return apply_filters( 'woocommerce_order_amount_total_tax', number_format( (double) $this->order_tax + (double) $this->order_shipping_tax, 2, '.', '' ) );
|
||||
return apply_filters( 'woocommerce_order_amount_total_tax', number_format( (double) $this->order_tax + (double) $this->order_shipping_tax, 2, '.', '' ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -418,7 +418,7 @@ class WC_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_cart_discount() {
|
||||
return apply_filters( 'woocommerce_order_amount_cart_discount', number_format( (double) $this->cart_discount, 2, '.', '' ) );
|
||||
return apply_filters( 'woocommerce_order_amount_cart_discount', number_format( (double) $this->cart_discount, 2, '.', '' ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -429,7 +429,7 @@ class WC_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_order_discount() {
|
||||
return apply_filters( 'woocommerce_order_amount_order_discount', number_format( (double) $this->order_discount, 2, '.', '' ) );
|
||||
return apply_filters( 'woocommerce_order_amount_order_discount', number_format( (double) $this->order_discount, 2, '.', '' ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -441,7 +441,7 @@ class WC_Order {
|
|||
*/
|
||||
public function get_total_discount() {
|
||||
if ( $this->order_discount || $this->cart_discount )
|
||||
return apply_filters( 'woocommerce_order_amount_total_discount', number_format( (double) $this->order_discount + (double) $this->cart_discount, 2, '.', '' ) );
|
||||
return apply_filters( 'woocommerce_order_amount_total_discount', number_format( (double) $this->order_discount + (double) $this->cart_discount, 2, '.', '' ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -452,7 +452,7 @@ class WC_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_shipping() {
|
||||
return apply_filters( 'woocommerce_order_amount_shipping', number_format( (double) $this->order_shipping, 2, '.', '' ) );
|
||||
return apply_filters( 'woocommerce_order_amount_shipping', number_format( (double) $this->order_shipping, 2, '.', '' ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -463,7 +463,7 @@ class WC_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_shipping_tax() {
|
||||
return apply_filters( 'woocommerce_order_amount_shipping_tax', number_format( (double) $this->order_shipping_tax, 2, '.', '' ) );
|
||||
return apply_filters( 'woocommerce_order_amount_shipping_tax', number_format( (double) $this->order_shipping_tax, 2, '.', '' ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -474,7 +474,7 @@ class WC_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_total() {
|
||||
return apply_filters( 'woocommerce_order_amount_total', number_format( (double) $this->order_total, 2, '.', '' ) );
|
||||
return apply_filters( 'woocommerce_order_amount_total', number_format( (double) $this->order_total, 2, '.', '' ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -506,7 +506,7 @@ class WC_Order {
|
|||
foreach ( $shipping_methods as $shipping )
|
||||
$labels[] = $shipping['name'];
|
||||
|
||||
return apply_filters( 'woocommerce_order_shipping_method', implode( ', ', $labels ) );
|
||||
return apply_filters( 'woocommerce_order_shipping_method', implode( ', ', $labels ), $this );
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -523,7 +523,7 @@ class WC_Order {
|
|||
$price = ( $item['line_subtotal'] + $item['line_subtotal_tax'] / $item['qty'] );
|
||||
else
|
||||
$price = ( $item['line_subtotal'] / $item['qty'] );
|
||||
return apply_filters( 'woocommerce_order_amount_item_subtotal', ($round) ? number_format( $price, 2, '.', '') : $price );
|
||||
return apply_filters( 'woocommerce_order_amount_item_subtotal', (($round) ? number_format( $price, 2, '.', '') : $price ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -541,7 +541,7 @@ class WC_Order {
|
|||
$price = $item['line_subtotal'] + $item['line_subtotal_tax'];
|
||||
else
|
||||
$price = $item['line_subtotal'];
|
||||
return apply_filters( 'woocommerce_order_amount_line_subtotal', ($round) ? number_format( $price, 2, '.', '') : $price );
|
||||
return apply_filters( 'woocommerce_order_amount_line_subtotal', ( ($round) ? number_format( $price, 2, '.', '') : $price ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -559,7 +559,7 @@ class WC_Order {
|
|||
$price = ( ( $item['line_total'] + $item['line_tax'] ) / $item['qty'] );
|
||||
else
|
||||
$price = $item['line_total'] / $item['qty'];
|
||||
return apply_filters( 'woocommerce_order_amount_item_total', ($round) ? number_format( $price, 2, '.', '') : $price );
|
||||
return apply_filters( 'woocommerce_order_amount_item_total', ( ($round) ? number_format( $price, 2, '.', '') : $price ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -573,7 +573,7 @@ class WC_Order {
|
|||
*/
|
||||
public function get_item_tax( $item, $round = true ) {
|
||||
$price = $item['line_tax'] / $item['qty'];
|
||||
return apply_filters( 'woocommerce_order_amount_item_tax', ($round) ? number_format( $price, 2, '.', '') : $price );
|
||||
return apply_filters( 'woocommerce_order_amount_item_tax', ( ($round) ? number_format( $price, 2, '.', '') : $price ), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -587,9 +587,9 @@ class WC_Order {
|
|||
*/
|
||||
public function get_line_total( $item, $inc_tax = false ) {
|
||||
if ( $inc_tax )
|
||||
return apply_filters( 'woocommerce_order_amount_line_total', number_format( $item['line_total'] + $item['line_tax'] , 2, '.', '') );
|
||||
return apply_filters( 'woocommerce_order_amount_line_total', number_format( $item['line_total'] + $item['line_tax'] , 2, '.', ''), $this );
|
||||
else
|
||||
return apply_filters( 'woocommerce_order_amount_line_total', number_format( $item['line_total'] , 2, '.', '') );
|
||||
return apply_filters( 'woocommerce_order_amount_line_total', number_format( $item['line_total'] , 2, '.', ''), $this );
|
||||
}
|
||||
|
||||
|
||||
|
@ -601,7 +601,7 @@ class WC_Order {
|
|||
* @return float
|
||||
*/
|
||||
public function get_line_tax( $item ) {
|
||||
return apply_filters( 'woocommerce_order_amount_line_tax', number_format( $item['line_tax'], 2, '.', '') );
|
||||
return apply_filters( 'woocommerce_order_amount_line_tax', number_format( $item['line_tax'], 2, '.', ''), $this );
|
||||
}
|
||||
|
||||
/** End Total Getters *******************************************************/
|
||||
|
@ -916,7 +916,7 @@ class WC_Order {
|
|||
'image_size' => $image_size
|
||||
) );
|
||||
|
||||
$return = apply_filters( 'woocommerce_email_order_items_table', ob_get_clean() );
|
||||
$return = apply_filters( 'woocommerce_email_order_items_table', ob_get_clean(), $this );
|
||||
|
||||
return $return;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue