Advertisement
Guest User

Untitled

a guest
Feb 11th, 2014
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.37 KB | None | 0 0
  1. function method_for_losers_use_variable_get_price_html( $price, $product ) {
  2.  
  3.     if ( $product instanceof WC_Product_Variable ) {
  4.         $price = '';
  5.  
  6.         // Get the price
  7.         if ( $product->price > 0 ) {
  8.             if ( $product->is_on_sale() && isset( $product->min_variation_price ) && $product->min_variation_regular_price !== $product->get_price() ) {
  9.  
  10.                 if ( ! $product->min_variation_price || $product->min_variation_price !== $product->max_variation_price )
  11.                     $price .= $product->get_price_html_from_text();
  12.  
  13.                 $price .= $product->get_price_html_from_to( $product->min_variation_regular_price, $product->get_price() );
  14.  
  15.                 $price = apply_filters( 'woocommerce_variable_sale_price_html', $price, $product );
  16.  
  17.             } else {
  18.  
  19.                 if ( $product->min_variation_price !== $product->max_variation_price )
  20.                     $price .= $product->get_price_html_from_text();
  21.  
  22.                 $price .= woocommerce_price( $product->get_price() );
  23.  
  24.                 $price = apply_filters('woocommerce_variable_price_html', $price, $product);
  25.  
  26.             }
  27.         } elseif ( $product->price === '' ) {
  28.  
  29.             $price = apply_filters('woocommerce_variable_empty_price_html', '', $product);
  30.  
  31.         } elseif ( $product->price == 0 ) {
  32.  
  33.             if ( $product->is_on_sale() && isset( $product->min_variation_regular_price ) && $product->min_variation_regular_price !== $product->get_price() ) {
  34.  
  35.                 if ( $product->min_variation_price !== $product->max_variation_price )
  36.                     $price .= $product->get_price_html_from_text();
  37.  
  38.                 $price .= $product->get_price_html_from_to( $product->min_variation_regular_price, __( 'Free!', 'woocommerce' ) );
  39.  
  40.                 $price = apply_filters( 'woocommerce_variable_free_sale_price_html', $price, $product );
  41.  
  42.             } else {
  43.  
  44.                 if ( $product->min_variation_price !== $product->max_variation_price )
  45.                     $price .= $product->get_price_html_from_text();
  46.  
  47.                 $price .= __( 'Free!', 'woocommerce' );
  48.  
  49.                 $price = apply_filters( 'woocommerce_variable_free_price_html', $price, $product );
  50.  
  51.             }
  52.         }
  53.     }
  54.  
  55.     return $price;
  56. }
  57.  
  58. 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