Advertisement
Guest User

Untitled

a guest
Jun 22nd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.93 KB | None | 0 0
  1. function wc_ninja_custom_variable_price( $price, $product ) {
  2. // Main Price
  3. $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
  4. $price = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
  5.  
  6. // Sale Price
  7. $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
  8. sort( $prices );
  9. $saleprice = $prices[0] !== $prices[1] ? sprintf( __( 'From: %1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
  10.  
  11. if ( $price !== $saleprice ) {
  12. $price = '' . $saleprice . ' ' . $price . '';
  13. }
  14.  
  15. return $price;
  16. }
  17. add_filter( 'woocommerce_variable_sale_price_html', 'wc_ninja_custom_variable_price', 10, 2 );
  18. add_filter( 'woocommerce_variable_price_html', 'wc_ninja_custom_variable_price', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement