Last active
December 7, 2022 13:12
-
-
Save FrancoStino/2cbb3e9c9e2fd530584d91f9bb185fdf to your computer and use it in GitHub Desktop.
Custom Price message meta key into cart item (IVA) - Woocommerce
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
<?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