Skip to content

Instantly share code, notes, and snippets.

@thesadoo
Created October 3, 2016 11:28
Show Gist options
  • Save thesadoo/8f9d97e4da1a787528d3d291649a2ff3 to your computer and use it in GitHub Desktop.
Save thesadoo/8f9d97e4da1a787528d3d291649a2ff3 to your computer and use it in GitHub Desktop.
Get WooCommerce product's discount percentage
<?php
global $product;
$sale_price = $product->sale_price;
$regu_price = $product->regular_price;
$percentage = round( ( ( $regu_price - $sale_price ) / $regu_price ) * 100 );
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment