Last active
January 19, 2021 08:56
-
-
Save FrancoStino/2ad8ab0842c25d652f4feee874bc1290 to your computer and use it in GitHub Desktop.
Add suffix price through tax name with slug
This file contains hidden or 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 suffix price through tax name with slug | |
*/ | |
add_filter( 'woocommerce_available_variation', 'custom_variation_price', 10, 3 ); | |
function custom_variation_price( $data, $product, $variation ) { | |
$price_excl_tax = (float) wc_get_price_excluding_tax( $variation ); // price without VAT | |
$price_incl_tax = (float) wc_get_price_including_tax( $variation ); // price with VAT | |
$tax_amount = $price_incl_tax - $price_excl_tax; | |
if( $variation->get_tax_class() === 'nessuna-tariffa' ) { | |
$data['price_html'] = wc_price($price_excl_tax) . __(' IVA INCLUSA'); | |
}else{ | |
$data['price_html'] = wc_price($price_excl_tax) . __(' IVA ESCLUSA'); | |
} | |
return $data; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment