Advertisement
Evengar

Untitled

Mar 8th, 2017
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.06 KB | None | 0 0
  1. <?php
  2. /**
  3.  * Your Inspiration Themes
  4.  *
  5.  * @package WordPress
  6.  * @subpackage Your Inspiration Themes
  7.  * @author Your Inspiration Themes Team <info@yithemes.com>
  8.  *
  9.  * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
  10.  * that is bundled with this package in the file LICENSE.txt.
  11.  * It is also available through the world-wide-web at this URL:
  12.  * http://www.gnu.org/licenses/gpl-3.0.txt
  13.  */
  14.  
  15. //let's start the game!
  16. require_once('core/load.php');
  17.  
  18. //---------------------------------------------
  19. // Everybody changes above will lose his hands
  20. //---------------------------------------------
  21.  
  22.  
  23.  
  24. function wc_ninja_custom_variable_price( $price, $product ) {
  25.     // Main Price
  26.     $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
  27.     $price = round($prices[0]) !== round($prices[1]) ? sprintf( __( 'prezzo da: %1$s', 'woocommerce' ), wc_price( round($prices[0]) ) ) : wc_price( round($prices[0])  );
  28.  
  29.     // Sale Price
  30.     $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
  31.     sort( $prices );
  32.     $saleprice = round($prices[0]) !== round($prices[1]) ? sprintf( __( 'prezzo da: %1$s', 'woocommerce' ), wc_price( round($prices[0]) ) ) : wc_price( round($prices[0]) );
  33.  
  34.     if ( $price !== $saleprice ) {
  35.         $price = '' . $saleprice . ' ' . $price . '';
  36.     }
  37.    
  38. return $price ;
  39. }
  40. add_filter( 'woocommerce_variable_sale_price_html', 'wc_ninja_custom_variable_price', 10, 2 );
  41. add_filter( 'woocommerce_variable_price_html', 'wc_ninja_custom_variable_price', 10, 2 );
  42.  
  43. add_filter( 'woocommerce_get_price_excluding_tax', 'round_price_product', 10, 1 );
  44. add_filter( 'woocommerce_get_price_including_tax', 'round_price_product', 10, 1 );
  45. add_filter( 'woocommerce_tax_round', 'round_price_product', 10, 1);
  46. add_filter( 'woocommerce_get_price', 'round_price_product', 10, 1);
  47.  
  48. function round_price_product( $price ){
  49.     // Return rounded price
  50.    $price = round($price) ;
  51. return $price ;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement