Hi,
I have built a website on WordPress that has a shop component where customers can buy products in the form of digital downloads. What I want to do is offer a subscription service where they could pay a monthly fee and get access to the whole shop with all products being free. I don’t really want to build another set of shop pages for the members only. I was wondering if there is some simple of signing members up and then telling the website that if they are logged in as a paying member all the products in the store become free.
Alternatively, could I do it with unique coupon codes that would be automatically generated and sent to them when they join as a member in an email that would give them 100% discount on all items when they are in the cart?
Thank you for your help in advance.
[ad_2]
`add_filter( ‘woocommerce_product_get_price’, ‘custom_discount_price’, 10, 2 );`
`add_filter( ‘woocommerce_product_variation_get_price’, ‘custom_discount_price’, 10, 2 );`
`function custom_discount_price( $price, $product ) {`
`// For logged in users`
`if ( is_user_logged_in() ) {`
`$price = 0;`
`}`
`return $price;`
`}`
You can change is_user_logged_in – and check for a user role or whatever. But if you have, say, Ultimate Member – you can let people sign-up, and then use this code to set all prices as zero.