Created
February 2, 2018 08:50
-
-
Save kreamweb/7f33d375e7a3e0a46c6322f6cf13834c to your computer and use it in GitHub Desktop.
Change the variation price with
FROM: ----
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_get_price_html', 'ywsbs_woocommerce_get_variation_price_html', 99, 2 ); | |
add_filter( 'woocommerce_get_variation_price_html', 'ywsbs_woocommerce_get_variation_price_html', 99, 2 ); | |
function ywsbs_woocommerce_get_variation_price_html( $price, $product ){ | |
if ( ! $product->is_type('variable') ){ | |
return $price; | |
} | |
$prefix = sprintf('%s: ', __('From', 'iconic')); | |
$min_price_regular = $product->get_variation_regular_price( 'min', true ); | |
$min_price_sale = $product->get_variation_sale_price( 'min', true ); | |
$max_price = $product->get_variation_price( 'max', true ); | |
$min_price = $product->get_variation_price( 'min', true ); | |
$price = ( $min_price_sale == $min_price_regular ) ? | |
wc_price( $min_price_regular ) : | |
'<del>' . wc_price( $min_price_regular ) . '</del>' . '<ins>' . wc_price( $min_price_sale ) . '</ins>'; | |
return ( $min_price == $max_price ) ? | |
$price : | |
sprintf('%s%s', $prefix, $price); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment