One of the features of the WooCommerce Memberships extension is the ability to offer purchasing discounts to your customers if they are a member of a qualifying membership plan. Many site owners sell subscription products and in many cases these subscription products are configured with a sign-up fee to cover on-boarding costs for the subscriber. Since a sign-up fee is a “fee” and not really part of the product price, Memberships does not (as of version 1.3.0) apply a discount to the sign-up fee. So, what if you want to offer a discount on the sign-up fee as well? Great news! There’s a filter for that!! I am going to use the Subscriptions provided filter named woocommerce_subscriptions_product_sign_up_fee which, as its name would suggest, can be used to filter the sign-up fee for a subscription product. The example below will only work with Memberships version 1.3.0 (or above) – since the sign-up fee filter passes the $product object as one of its variables, that object can, in turn, be passed to the Memberships provided class named WC_Memberships_Member_Discounts and processed by the method named get_discounted_price to get an appropriate cost adjustment for the subscription product sign-up fee.
Before using the following code snippet, make sure and take a look at the changelog for Memberships as discounts for subscription sign-up fees may have already been added – but if it hasn’t this should serve as a workaround until then:
Not sure what to do with code snippets? See What Do I Do With These Code Snippets?