';
//if product is in sale but sale price is not set
if ( ($price_amt != $regular_price) && $sale_price === '' ) {
$html_price .= '' . wc_price($price_amt) . '';
$html_price .= '' . wc_price($regular_price) . '';
}
//if product is in sale
if (($price_amt == $sale_price) && ($sale_price != 0)) {
$html_price .= '' . wc_price($sale_price) . '';
$html_price .= '' . wc_price($regular_price) . '';
}
//in sale but free
else if (($price_amt == $sale_price) && ($sale_price == 0)) {
$html_price .= 'Free!';
$html_price .= '' . wc_price($regular_price) . '';
}
//not is sale
else if (($price_amt == $regular_price) && ($regular_price != 0)) {
$html_price .= '' . wc_price($regular_price) . '';
}
//for free product
else if (($price_amt == $regular_price) && ($regular_price == 0)) {
$html_price .= 'Free!';
}
$html_price .= '
';
$html_price .= '' . wc_price($variation_min_price) . '-' . wc_price($variation_max_price) . '';
$html_price .= '' . wc_price($variation_min_regular_price) . '-' . wc_price($variation_max_regular_price) . '';
$html_min_max_price = $html_price;
}
return $html_min_max_price;
}
//najnizsza cena w wariancie
add_filter( 'woocommerce_variable_sale_price_html', 'wc_wc20_variation_price_format', 10, 2 );
add_filter( 'woocommerce_variable_price_html', 'wc_wc20_variation_price_format', 10, 2 );
function wc_wc20_variation_price_format( $price, $product ) {
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
$price = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
// Sale Price
$prices = array( $product->get_variation_regular_price( 'min', true ), $product->get_variation_regular_price( 'max', true ) );
sort( $prices );
$saleprice = $prices[0] !== $prices[1] ? sprintf( __( '%1$s', 'woocommerce' ), wc_price( $prices[0] ) ) : wc_price( $prices[0] );
if ( $price !== $saleprice ) {
$price = '' . $saleprice . ' ' . $price . '';
}
return $price;
}
//NUMBER OF PRODUCTS TO DISPLAY ON SHOP PAGE
add_action('pre_get_posts', 'wg_view_all_products', 999);
function wg_view_all_products($query){
if( isset($_GET['view']) && $_GET['view'] === 'all' ){
$query->set( 'posts_per_page', -1 );
}
}