Last active
November 6, 2022 11:05
-
-
Save EricBusch/8812595 to your computer and use it in GitHub Desktop.
Display the Savings discount for a product that's on sale on product list pages.
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