• Resolved totoro-paris

    (@totoro-paris)


    Hello
    with your fine plugin Advanced Dynamic Pricing for WooCommerce, i need to add text after discount price in product page => like this one : / spécial price -{percentage-discount}
    how can i do this ?
    Thxs for your help

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Support thisisirene

    (@thisisirene)

    Hello, @totoro-paris!

    You can replace the price by the template using Pricing rules>Settings>Product price>Product price html template.

    Thread Starter totoro-paris

    (@totoro-paris)

    thxs for your quick answer !
    but what means : Only for products already in cart ?
    It doesn’t work for all product pages ?
    how can i do to have 360,00€ 356,40€ / special price -{percentage-discount} ?
    what are all the tags ?
    Thx for your help
    .cedric

    Plugin Support thisisirene

    (@thisisirene)

    @totoro-paris, sorry for the confusion in my first reply!
    You can use option “Pricing rules>Settings>Product page>Show total price for product” and create a template for the total price as you need it: https://snipboard.io/RqfxAK.jpg

    How it looks on the product page: https://snipboard.io/XIYsey.jpg

    But it’s pro version feature. You can submit a new ticket to our helpdesk, and we will give you pro version for tests.

    Thread Starter totoro-paris

    (@totoro-paris)

    Thxs
    Can we have custom price text with tags for the product price ? just under the product title
    thxs

    Plugin Author algol.plus

    (@algolplus)

    hi

    Could you try this code ?

    add_filter( 'woocommerce_get_price_html', function ( $old_html, $product ) {
        $new_html = '';
        if ($product->get_type() == 'variable') {
            $processedProduct = adp_functions()->calculateProduct($product, 1);
            if ($processedProduct instanceof \ADP\BaseVersion\Includes\PriceDisplay\ProcessedVariableProduct &&
                !is_null($processedProductLowestPrice = $processedProduct->getLowestPriceProduct()) &&
                $processedProduct->areRulesApplied()) {
                $minVariationPrice = $processedProductLowestPrice->getCalculatedPrice();
                $initialPrice = $processedProductLowestPrice->getOriginalPrice();
                $percentage = round((($initialPrice - $minVariationPrice) / $initialPrice) * 100);
    	    if($percentage)
            	$new_html =  wc_price($minVariationPrice) . " - %" . $percentage;
            } elseif ($product->is_on_sale()) {
                $available_variations = $product->get_variation_prices();
                $max_percentage = 0;
                foreach ($available_variations['regular_price'] as $key => $regular_price) {
                    $sale_price = $available_variations['sale_price'][$key];
    
                    if ($sale_price < $regular_price) {
                        $percentage = round((($regular_price - $sale_price) / $regular_price) * 100);
                        if ($percentage > $max_percentage) {
                            $max_percentage = $percentage;
    	                $minVariationPrice = $sale_price ;
                        }
                    }
                }
                $percentage = $max_percentage;
    	    if($percentage)
            	$new_html =  wc_price($minVariationPrice) . " - %" . $percentage;
            }
        } elseif ($product->get_type() == 'simple' || $product->get_type() == 'external' || $product->get_type() == 'variation') {
            $processedProduct = adp_functions()->calculateProduct($product, 1);
            if ($processedProduct instanceof \ADP\BaseVersion\Includes\PriceDisplay\ProcessedProductSimple &&
                $processedProduct->areRulesApplied()) {
                $initialPrice = $processedProduct->getOriginalPrice();
                $calculatedPrice = $processedProduct->getCalculatedPrice();
                $percentage = round((($initialPrice - $calculatedPrice) / $initialPrice) * 100);
            } elseif ($product->is_on_sale()) {
                $calculatedPrice = $product->get_sale_price();
                $percentage = round((($product->get_regular_price() - $product->get_sale_price()) / $product->get_regular_price()) * 100);
            }
            if($percentage)
            	$new_html =  wc_price($calculatedPrice) . " - %" . $percentage;
        }
    
        return $new_html ? $new_html : $old_html;
    }, PHP_INT_MAX, 2 );
    Thread Starter totoro-paris

    (@totoro-paris)

    ok thxs

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Add text after discount price in product page’ is closed to new replies.