Guest User

Untitled

a guest
Dec 1st, 2017
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.96 KB | None | 0 0
  1. add_filter( 'woocommerce_variable_sale_price_html', 'wc_shopy_variation_price_format', 10, 2 );
  2. add_filter( 'woocommerce_variable_price_html', 'wc_wc_shopy_variation_price_format', 10, 2 );
  3.  
  4. function wc_shopy_variation_price_format( $price, $product ) {
  5.     $min_price = $product->get_variation_price( 'min', true );
  6.     if ( $product->product_type == 'variable' && is_product_category( 'promotions' ) ) {
  7.             $available_variations = $product->get_available_variations();
  8.             for ($i = 0; $i < count($available_variations); ++$i) {
  9.                 $variation_id = $available_variations[$i]['variation_id'];
  10.                 $variable_product1 = new WC_Product_Variation($variation_id);
  11.                 $regular_price = $variable_product1->regular_price;
  12.             }
  13.         $price = sprintf( __( 'A partir de %1$s <ins>%2$s</ins>', 'woocommerce' ), wc_price( $regular_price ) , wc_price( $min_price ) );
  14.     } else {
  15.         $price = sprintf( __( 'A partir de %1$s', 'woocommerce' ), wc_price( $min_price ) );
  16.     }
  17.     return $price;
  18. }
Advertisement
Add Comment
Please, Sign In to add comment