Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- * Your Inspiration Themes
- *
- * @package WordPress
- * @subpackage Your Inspiration Themes
- * @author Your Inspiration Themes Team <info@yithemes.com>
- *
- * This source file is subject to the GNU GENERAL PUBLIC LICENSE (GPL 3.0)
- * that is bundled with this package in the file LICENSE.txt.
- * It is also available through the world-wide-web at this URL:
- * http://www.gnu.org/licenses/gpl-3.0.txt
- */
- //let's start the game!
- require_once('core/load.php');
- //---------------------------------------------
- // Everybody changes above will lose his hands
- //---------------------------------------------
- function wc_ninja_custom_variable_price( $price, $product ) {
- // Main Price
- $prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
- $price = round($prices[0]) !== round($prices[1]) ? sprintf( __( 'prezzo da: %1$s', 'woocommerce' ), wc_price( round($prices[0]) ) ) : wc_price( round($prices[0]) );
- // Sale Price
- $prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
- sort( $prices );
- $saleprice = round($prices[0]) !== round($prices[1]) ? sprintf( __( 'prezzo da: %1$s', 'woocommerce' ), wc_price( round($prices[0]) ) ) : wc_price( round($prices[0]) );
- if ( $price !== $saleprice ) {
- $price = '' . $saleprice . ' ' . $price . '';
- }
- return $price ;
- }
- add_filter( 'woocommerce_variable_sale_price_html', 'wc_ninja_custom_variable_price', 10, 2 );
- add_filter( 'woocommerce_variable_price_html', 'wc_ninja_custom_variable_price', 10, 2 );
- add_filter( 'woocommerce_get_price_excluding_tax', 'round_price_product', 10, 1 );
- add_filter( 'woocommerce_get_price_including_tax', 'round_price_product', 10, 1 );
- add_filter( 'woocommerce_tax_round', 'round_price_product', 10, 1);
- add_filter( 'woocommerce_get_price', 'round_price_product', 10, 1);
- function round_price_product( $price ){
- // Return rounded price
- $price = round($price) ;
- return $price ;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement