Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FrancoStino/2ad8ab0842c25d652f4feee874bc1290 to your computer and use it in GitHub Desktop.
Save FrancoStino/2ad8ab0842c25d652f4feee874bc1290 to your computer and use it in GitHub Desktop.
Add suffix price through tax name with slug
<?
/*
* 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