/** * Check if a product has a member discount * Example: Display a member discount notice */ function sv_wc_memberships_member_discount_product_notice() { // bail if Memberships isn't active if (!function_exists('wc_memberships')) { return; } // Set a discount end date $discount_ends = date_i18n(wc_date_format(), strtotime('2015-12-31')); // Add our top notice if the member has a discount if (wc_memberships_user_has_member_discount()) { wc_print_notice(sprintf('Act fast! Your member discount ends on %s.', $discount_ends), 'notice'); } }
* * DISCLAIMER * * Do not edit or add to this file if you wish to upgrade WooCommerce Memberships to newer * versions in the future. If you wish to customize WooCommerce Memberships for your * needs please refer to http://docs.woothemes.com/document/woocommerce-memberships/ for more information. * * @package WC-Memberships/Templates * @author SkyVerge * @copyright Copyright (c) 2014-2015, SkyVerge, Inc. * @license http://www.gnu.org/licenses/gpl-3.0.html GNU General Public License v3.0 */ if (!defined('ABSPATH')) { exit; } // Exit if accessed directly /** * Single Product Member Discount Badge * * @since 1.0.0 */ global $post, $product; if (wc_memberships_user_has_member_discount()) { ?> <?php echo apply_filters('wc_memberships_member_discount_badge', '<span class="onsale wc-memberships-member-discount">' . esc_html__('Member discount!', WC_Memberships::TEXT_DOMAIN) . '</span>', $post, $product); ?> <?php }
/** * Display member discount message for product * * @since 1.0.0 */ public function single_product_member_discount_message() { global $product; if (wc_memberships_product_has_member_discount() && !wc_memberships_user_has_member_discount()) { $message = wc_memberships()->frontend->get_member_discount_message($product->id); if ($message) { echo '<div class="woocommerce"><div class="woocommerce-info wc-memberships-member-discount-message">' . wp_kses_post($message) . '</div></div>'; } } }