Skip to content

Instantly share code, notes, and snippets.

@bstonedev
Created March 13, 2020 00:48
Show Gist options
  • Save bstonedev/6455ef10eecf782ae07a0f555871aec4 to your computer and use it in GitHub Desktop.
Save bstonedev/6455ef10eecf782ae07a0f555871aec4 to your computer and use it in GitHub Desktop.
Find discount amount for WooCommerce Product
<?php
$product = wc_get_product($product_id);
if( $product->is_on_sale() ) {
$discount = $product->get_regular_price() - $product->get_sale_price();
}
else {
$discount = 0;
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment