A
A
Alexander2017-02-01 01:01:53
WordPress
Alexander, 2017-02-01 01:01:53

What is the best plugin to use to display discounts?

Hello.
The plugin must have the following two fundamental features:
1) Allows you to set a discount in percentage terms.
2) Allows you to display this discount in the product card preview

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Kozlov, 2017-02-01
@trampick

Why a plugin? woocommerce has a built in old and new price feature. You only need to edit 2 templates for a product card in the catalog and for a single product card.
These files should be in your theme folder:
woocommerce/loop/sale-flash.php - for the
woocommerce/single-product/sale-flash.php directory - for a single card
To show %, not just the word discount (by default) you need to upgrade the script in this form:

if (!defined('ABSPATH')) {
    exit; 
}
global $post, $product;
$id = $product->id;
if ($product->is_on_sale()) {
    $price = get_field('_price', $id);
    $regular_price = get_field('_regular_price', $id);
    ?>
    <span class="sale"><span><?php echo round(100 - ($price / $regular_price) * 100); ?>%</span></span>
    <?php
}

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question