• Resolved Teo Dereta

    (@tdereta)


    Hi,

    I installed PMPro to sell recurring Memberships and Products through Woocommerce. In the PMPro settings I have created a Gold membership level that has a global percent discount for all products in Woocommerce.

    If a user purchases a Gold membership level (which in my case is also a product), he gets a 30% discount for all products. The problem is that now all Gold members see the price for this Gold membership level with a 30% discount and I don’t want that discount to affect the membership price. Is there a way for the global discount to avoid affecting the membership price? Recurring membership payment is set to monthly payments with Woocommerce Subscription add-on. Will the Gold member pay the full price for the next month membership or with the 30% discount? I hope you understand the issue I’m having.

    Thank you so much for your help!

    Teo

Viewing 2 replies - 1 through 2 (of 2 total)
  • Plugin Author Andrew Lima

    (@andrewza)

    Hi Teo,

    Thank you for using Paid Memberships Pro.

    Under “Advanced” Settings of Paid Memberships Pro, you are able to set the “Apply Member Discounts to WooCommerce Subscription and Membership Products?” to “No” which should prevent discounting of membership products.

    For Paid Memberships Pro WooCommerce related questions, you may post your questions here – https://wordpress.org/support/plugin/pmpro-woocommerce/

    I hope this helps get you started.

    Thread Starter Teo Dereta

    (@tdereta)

    Hi Andrew,

    Thank you for your reply!

    Yes, I have already tried your suggestion and switched it to “no”. But then all products including the memberships are affected because it says “Apply Member Discounts to Woocommerce subscriptions and Membership Products”. All products in my woocommerce are membership products. If it only affected memberships, than it would be a solution.

    I googled a little bit and found your code snippet on github that finally resolves this issue. I hope it will help others too. You can close this topic since I found the resolution.

    Thank you and bye!
    Teo

    /**
     * This will exclude products that belong to a specific category from the membership discount.
     * Add the below code to your PMPro Customizations Plugin - https://www.paidmembershipspro.com/create-a-plugin-for-pmpro-customizations/
     */
     
    function my_pmpro_exclude_woocommerce_discounts_for_categories( $price, $level_id, $original_price, $product ) {
    
    	// Array of categories to exclude, uses category slug.
    	$exclude_categories = array( 'category-1', 'category-2', 'category-3' );
    
    	// Figure out if product is a variation or simple product.
    	if ( $product->get_type() === 'variation' ) {
    		$product_id = $product->get_parent_id();
    	} else {
    		$product_id = $product->get_id();
    	}
    
    	$category_data = wp_get_post_terms( $product_id, 'product_cat' );
    
    	// Check if product belongs to a category and remove discounted pricing.
    	foreach( $category_data as $key => $value ) {
    		if ( in_array( $value->slug, $exclude_categories ) ) {
    			$price = $original_price;
    		}
    	}
    
    	return $price;
    }
    add_filter( 'pmprowoo_get_membership_price', 'my_pmpro_exclude_woocommerce_discounts_for_categories', 10, 4 );
Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Global Percent Discount for all products’ is closed to new replies.