Atanu Bhunia
Forum Replies Created
-
Forum: Plugins
In reply to: [WooCommerce] How To Show Discount Percentage In Admin Product ListHello,
Can anyone help me regarding this?Forum: Plugins
In reply to: [WooCommerce] How To Show Discount Percentage In Admin Product ListThanks for your reply. Actually I used some lines of code to my theme’s function.php to show the discount percentage in Frontend of Single Product Page just below of Product Pricing. Below is the code
function dc_your_discount() {
global $product;
if( $product->is_type(‘simple’) || $product->is_type(‘external’) || $product->is_type(‘grouped’) ) {
$regular_price = get_post_meta( $product->get_id(), ‘_regular_price’, true );
$sale_price = get_post_meta( $product->get_id(), ‘_sale_price’, true );if( !empty($sale_price) ) {
$amount_saved = $regular_price – $sale_price;
$currency_symbol = get_woocommerce_currency_symbol();$percentage = round( ( ( $regular_price – $sale_price ) / $regular_price ) * 100 );
?>
<p style=”font-size:16px;color:red;”><b>You Save: <?php echo number_format($percentage,0, ”, ”).’%’; ?></b></p>
<?php
}
}
}add_action( ‘woocommerce_single_product_summary’, ‘dc_your_discount’, 11 );
Thanks a lot to mention the problem. Yes you are right, this is happening for outdated API. Anyway this topic can be closed here. Thanks again.