Advertisement
Fany_VanDaal

"Cena od" u variabilních produktů

Jan 24th, 2020
616
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.97 KB | None | 0 0
  1. function vandaal_variable_price_format( $price, $product ) {
  2.  
  3.     $prefix = sprintf('%s: ', __('Od', 'vandaal')); // zde si zadejte co má být před cenou, například Od nebo Cena Od
  4.  
  5.     $min_price_regular = $product->get_variation_regular_price( 'min', true );
  6.     $min_price_sale    = $product->get_variation_sale_price( 'min', true );
  7.     $max_price = $product->get_variation_price( 'max', true );
  8.     $min_price = $product->get_variation_price( 'min', true );
  9.  
  10.     $price = ( $min_price_sale == $min_price_regular ) ?
  11.         wc_price( $min_price_regular ) :
  12.         '<del>' . wc_price( $min_price_regular ) . '</del>' . '<ins>' . wc_price( $min_price_sale ) . '</ins>';
  13.  
  14.     return ( $min_price == $max_price ) ?
  15.         $price :
  16.         sprintf('%s%s', $prefix, $price);
  17.  
  18. }
  19.  
  20. add_filter( 'woocommerce_variable_sale_price_html', 'vandaal_variable_price_format', 10, 2 );
  21. add_filter( 'woocommerce_variable_price_html', 'vandaal_variable_price_format', 10, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement