WooCommerce toon Vanaf prijs en geen prijsrange bij aanbiedingen

Dit bericht is een aanvulling op het eerder geplaatste bericht “WooCommerce toon Vanaf prijs en geen prijsrange“.

Bij de functie in bovenstaand bericht werd de prijs niet aangepast wanneer producten met een range in de aanbieding zijn.

Als je onderstaande functie toevoegt aan je functions.php bestand dan zie je in plaats van:

€ 1.000 tot € 2.000 € 900 tot 1.800″

Dit staan:

“Vanaf € 1.000 € 900″

Je ziet dus de originele minimale prijs doorgestreept gevolgd door de minimale aanbiedingsprijs. Werkt voor overzichts- en detailpagina’s.

/**
* Show a minimum price for products with a sale price.
*/
add_filter('woocommerce_variable_sale_price_html', 'custom_variation_saleprice', 10, 2);
function custom_variation_saleprice( $price, $product ) {
if ($product->min_variation_price && $product-><span style="display: inline-block; width: 0px; overflow: hidden; line-height: 0;" data-mce-type="bookmark" class="mce_SELRES_start"></span>min_variation_regular_price) {
$price = '<span class="from">Vanaf</span> ';
$price .= woocommerce_price($product->min_variation_regular_price);
$price .= woocommerce_price($product->min_variation_price);
}

return $price;
}

Getest op: WordPress 3.8.2 en Woocommerce 2.1.6.

16 reacties

Laat een antwoord achter aan Tim de Hoog Reactie annuleren

Your email address will not be published. Required fields are marked *

Deze site gebruikt Akismet om spam te verminderen. Bekijk hoe je reactie-gegevens worden verwerkt.