2

I'm using the WooCommerce Membership plugin to display member discounts on the Product page. Now I want to display the discount you could get with a membership for non member.

This is what I see when I'm not a member:

This is what i see when i'm not a member

This is what I see when I'm a member:

This is what I see when I'm a member

This is what I want to see when I'm not a member:

This is what i want to see when i'm not a member

Community
  • 1
  • 1
Yung_Coco
  • 23
  • 5

2 Answers2

1

I'm amazed how many times this question has been asked on the web and still no answer. Here's the solution I was able to come up with:

add_action( 'woocommerce_single_product_summary', 'neonbrand_show_member_price_non_members' );
function neonbrand_show_member_price_non_members($price) {
    global $product;
    if ( $product->is_type( 'variable' ) ) {
        $variations = $product->WC_Product_Variable::get_available_variations();
        $variations_id = wp_list_pluck( $variations, 'variation_id' );

        if ( ! wc_memberships_is_user_active_member( get_current_user_id(), 'vip-membership' ) ) {
            $a = get_option( 'wc_memberships_rules' );
            foreach($a as $value) {
                if(!empty(array_intersect($variations_id, $value['object_ids']))) {
                    $discount = $value['discount_amount'];
                    $nonmember_price = $product->get_price();
                    $member_price[] = $nonmember_price - $discount;
                }
            }
            echo '<p class="price"><b><i>Member Price As Low As: $'.min($member_price).'</i></b></p>';
        }
    }
}

I have variations on most products so that's why I had to implement the "Member Price As Low As" because the variations had different discounts. Obviously the incentive for all of this is to get people to become members.

enter image description here

This should be a feature of the plugin IMO. But ‍♂️

0

I have found a solution:

 echo wc_memberships()->get_member_discounts_instance() >get_product_discount($product->id);

with this code you can find the discount.

let me know.