-
-
Save EricBusch/1f67840e6272a227b719bdf9eb0b07af to your computer and use it in GitHub Desktop.
Display the Savings discount for a product that's on sale on product list/loop pages. Example: "Save 20%"
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Display the Savings discount for a product that's on sale on product list pages. | |
*/ | |
add_action( 'woocommerce_after_shop_loop_item', 'mycode_show_discount_in_product_lists' ); | |
function mycode_show_discount_in_product_lists() { | |
global $product; | |
$salediscount = get_post_meta( $product->id, '_dfrps_salediscount', true ); | |
if ( $salediscount > 0 ) { | |
echo '<div class="dfrps_salediscount">'; | |
echo 'Save ' . $salediscount . '%'; | |
echo '</div>'; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment