Created
January 3, 2018 16:27
-
-
Save twern/ec68a1cef5115b03f48b2c027d3d57af to your computer and use it in GitHub Desktop.
German Market - Filter - Nebenangaben in den Produkten aus der Mail entfernen entfernen
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add_action( 'woocommerce_email_header', 'action_for_remove_tax_from_order_items_in_emails' ); | |
add_action( 'woocommerce_email_footer', 'remove_filter_for_remove_tax_from_order_items_in_emails' ); | |
function action_for_remove_tax_from_order_items_in_emails() { | |
add_filter( 'woocommerce_order_formatted_line_subtotal', 'remove_tax_from_order_items_in_emails', 10, 3 ); | |
add_filter( 'woocommerce_order_shipping_to_display', 'remove_tax_from_shipping_in_emails', 10, 2 ); | |
} | |
function remove_filter_for_remove_tax_from_order_items_in_emails() { | |
remove_filter( 'woocommerce_order_formatted_line_subtotal', 'remove_tax_from_order_items_in_emails', 10, 3 ); | |
remove_filter( 'woocommerce_order_shipping_to_display', 'remove_tax_from_shipping_in_emails', 10, 2 ); | |
} | |
function remove_tax_from_order_items_in_emails( $subtotal, $item, $order ) { | |
$tax_display = get_option( 'woocommerce_tax_display_cart' ); | |
if ( 'excl' == $tax_display ) { | |
$ex_tax_label = $order->get_prices_include_tax() ? 1 : 0; | |
$subtotal = wc_price( $order->get_line_subtotal( $item ), array( 'ex_tax_label' => $ex_tax_label, 'currency' => $order->get_currency() ) ); | |
} else { | |
$subtotal = wc_price( $order->get_line_subtotal( $item, true ), array( 'currency' => $order->get_currency() ) ); | |
} | |
return $subtotal; | |
} | |
function remove_tax_from_shipping_in_emails( $shipping, $order ) { | |
$tax_display = get_option( 'woocommerce_tax_display_cart' ); | |
if ( $order->get_shipping_total() != 0 ) { | |
if ( 'excl' == $tax_display ) { | |
$shipping = wc_price( $order->get_shipping_total(), array( 'currency' => $order->get_currency() ) ); | |
} else { | |
$shipping = wc_price( $order->get_shipping_total() + $order->get_shipping_tax() , array( 'currency' => $order->get_currency() ) ); | |
} | |
$shipping .= apply_filters( 'woocommerce_order_shipping_to_display_shipped_via', ' <small class="shipped_via">' . sprintf( __( 'via %s', 'woocommerce' ), $order->get_shipping_method() ) . '</small>', $order ); | |
} elseif ( $order->get_shipping_method() ) { | |
$shipping = $order->get_shipping_method(); | |
} else { | |
$shipping = __( 'Free!', 'woocommerce' ); | |
} | |
return $shipping; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment