A
A
Andrey2016-05-14 11:35:00
Programming
Andrey, 2016-05-14 11:35:00

How to add the word Discount before the percentage?

Hey!
I'm going to add the word "Discount" to the products on WooCommerce before the percentage.
Who knows php well, tell me where in the code you need to add the word?
PHP code:

<?php elseif($product->is_on_sale() && $flatsome_opt['sale_bubble_percentage'] && $product->product_type == 'simple') : ?>
<div class="callout <?php echo $flatsome_opt['bubble_style']; ?>">
    <div class="inner">
      <div class="inner-text"><?php 
    	$price = '';
    $percentage = round( ( ( $product->regular_price - $product->sale_price ) / $product->regular_price ) * 100,0);
    echo '-'.$price . sprintf( __('%s', 'woocommerce' ), $percentage . '%' ); ?></div>
    </div>
</div><!-- end callout -->

Displayed code on the site:
<div class="callout style2">
    <div class="inner">
      <div class="inner-text">-7%</div>
    </div>
</div><!-- end callout -->

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
landergate, 2016-05-14
@01chernov

echo 'Скидка -'.$price . sprintf( __('%s', 'woocommerce' ), $percentage . '%' ); ?></div>

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question