Created
January 6, 2022 19:47
-
-
Save Xiradorn/3de4098e35502567fa9e4b736ef716c5 to your computer and use it in GitHub Desktop.
Function for display ogni min (or max) price inside woo shop page / product page
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
<?php | |
/** | |
* Function for display ogni min (or max) price inside woo shop page / product page | |
*/ | |
function wc_varb_price_range( $wcv_price, $product ) { | |
$prefix = sprintf('%s: ', __('From', 'wcvp_range')); | |
$wcv_reg_min_price = $product->get_variation_regular_price( 'min', true ); | |
$wcv_min_sale_price = $product->get_variation_sale_price( 'min', true ); | |
$wcv_max_price = $product->get_variation_price( 'max', true ); | |
$wcv_min_price = $product->get_variation_price( 'min', true ); | |
$wcv_price = ( $wcv_min_sale_price == $wcv_reg_min_price ) ? | |
wc_price( $wcv_reg_min_price ) : | |
'<del>' . wc_price( $wcv_reg_min_price ) . '</del>' . '<ins>' . wc_price( $wcv_min_sale_price ) . '</ins>'; | |
return ( $wcv_min_price == $wcv_max_price ) ? | |
$wcv_price : | |
sprintf('%s%s', $prefix, $wcv_price); | |
} | |
add_filter( 'woocommerce_variable_sale_price_html', 'wc_varb_price_range', 10, 2 ); | |
add_filter( 'woocommerce_variable_price_html', 'wc_varb_price_range', 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@Xiradorn
prego aggiunga :