Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save FrancoStino/2cbb3e9c9e2fd530584d91f9bb185fdf to your computer and use it in GitHub Desktop.
Save FrancoStino/2cbb3e9c9e2fd530584d91f9bb185fdf to your computer and use it in GitHub Desktop.
Custom Price message meta key into cart item (IVA) - Woocommerce
<?php
add_filter( 'woocommerce_cart_item_subtotal', 'kd_custom_price_message', 10, 3 );
function kd_custom_price_message( $price_html, $cart_item, $cart_item_key ) {
if (!empty($cart_item['_cpo_calc_option'])) {
foreach ($cart_item as $key => $value) {
if(is_array($value)){
if(array_key_exists('uni_cpo_iva10', $value)) {
$afterPriceSymbol = ' <small class="tax_label">(IVA incl. 10%)</small>';
}elseif(array_key_exists('uni_cpo_iva22', $value)) {
$afterPriceSymbol = ' <small class="tax_label">(IVA incl. 22%)</small>';
}
}
}
}else{
$afterPriceSymbol = ' <small class="tax_label">(IVA incl. 22%)</small>';
}
return $price_html . $afterPriceSymbol;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment