Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function method_for_losers_use_variable_get_price_html( $price, $product ) {
- if ( $product instanceof WC_Product_Variable ) {
- $price = '';
- // Get the price
- if ( $product->price > 0 ) {
- if ( $product->is_on_sale() && isset( $product->min_variation_price ) && $product->min_variation_regular_price !== $product->get_price() ) {
- if ( ! $product->min_variation_price || $product->min_variation_price !== $product->max_variation_price )
- $price .= $product->get_price_html_from_text();
- $price .= $product->get_price_html_from_to( $product->min_variation_regular_price, $product->get_price() );
- $price = apply_filters( 'woocommerce_variable_sale_price_html', $price, $product );
- } else {
- if ( $product->min_variation_price !== $product->max_variation_price )
- $price .= $product->get_price_html_from_text();
- $price .= woocommerce_price( $product->get_price() );
- $price = apply_filters('woocommerce_variable_price_html', $price, $product);
- }
- } elseif ( $product->price === '' ) {
- $price = apply_filters('woocommerce_variable_empty_price_html', '', $product);
- } elseif ( $product->price == 0 ) {
- if ( $product->is_on_sale() && isset( $product->min_variation_regular_price ) && $product->min_variation_regular_price !== $product->get_price() ) {
- if ( $product->min_variation_price !== $product->max_variation_price )
- $price .= $product->get_price_html_from_text();
- $price .= $product->get_price_html_from_to( $product->min_variation_regular_price, __( 'Free!', 'woocommerce' ) );
- $price = apply_filters( 'woocommerce_variable_free_sale_price_html', $price, $product );
- } else {
- if ( $product->min_variation_price !== $product->max_variation_price )
- $price .= $product->get_price_html_from_text();
- $price .= __( 'Free!', 'woocommerce' );
- $price = apply_filters( 'woocommerce_variable_free_price_html', $price, $product );
- }
- }
- }
- return $price;
- }
- add_filter( 'woocommerce_get_price_html', 'method_for_losers_use_variable_get_price_html', 1, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement