In WooCommerce, I have 3 membership tiers (silver, gold and platinum) and I applied higher discount rate for higher membership tier.
I would like show the 4 different prices (non-member, silver, gold and platinum) to everyone such that they know how much they can save on each product if they join the membership. For example:
- Regular Price: $100
- Silver Member: $90
- Gold Member: $80
- Platinum Member: $70
I tried the code below:
function bsc_wc_memberships_members_only_product_price() {
global $product;
$user = wp_get_current_user();
if ( !wc_memberships_is_user_active_member($user->ID, 'test') ) {
$id = $product->get_id();
$discount = get_post_meta( $id, 'member_price', true );
$price = $product->get_price();
echo 'Member price: $'.$total = $price - $discount;
}
}
add_action( 'woocommerce_before_add_to_cart_button', 'bsc_wc_memberships_members_only_product_price' );
But it doesn't really work unfortunately... Any advice will be highly appreciated.