Woocommerce Subscriptions Extension – Date Based Access

HistoryWM Shop Page

History West Midlands is a quarterly magazine. They wanted to use Woocommerce subscriptions in combination with Woocommerce groups to restrict access to content to those with an active subscription, but more than that they wanted a subscription to buy access to exactly 4 issues, the current issue and the next 3, based on the date they subscribed. For this I wrote an extension, Date Based Access.

My plugin takes the 4 months that they plan to publish in, March, June, September, and December, and uses it to get the first issue a user has access to based on the dates of their active subscriptions (if you are logged in of course), and then sets the last day a year later, but also uses the cycling through the user’s subscriptions to get the latest last issue date as well were applicable. These dates are then used to build a user meta Access Issues.

This user meta is used on the my account page, where the user sees the list of issues they have access to.

HistoryWM Shop Page

Shop page, where you can see only subscriptions sold in the main section, and back issues the user doesn’t already have access for sale below

My extension also changes the shop page as well. For a start the main shop section only shows subscriptions.  Then below that in a second loop you can buy back issues. My plugin also builds a start date and end date for the current date, so it knows what issues would a subscription bought today have access to. It uses this to ensure that only back-issues not in the current subscription are for sale, and also excludes issues the user has already bought from this loop as well – again using the access_issues user meta. Finally when a back issue is purchased this is also added to the user’s access_issues meta.

Finally they wanted to use Issuu to allow the user to read the issues they had purchased. For this I created a custom query var view-issue and made it a post meta on the same key. The ?view-issue is passed through the url and used to query the posts and find out if the user has access to that issue, before then building the swf object with the correct issuu url. Job Done.

Do leave a comment if you would like to know more about this project or anything else you want to talk about.

The chances are I built the above for one of my freelance clients. You can hire me at Codeable.io - an WordPress specialist outsourcing site that vets developers to make sure they are of the highest standard.

Posted in Featured, Woocommerce, Wordpress.

5 Comments

  1. I was wondering if this works if a user puts their account on hold? Say you publish in March, June, September, and December. User starts their subscription in March, puts it on hold, then reactivates in September. Do they get access to March, September, December, and March again?

    • Hi Chuck,

      No, I am afraid I didn’t factor subscriptions being put on hold into the extension at all. I will get in touch with the Subscriptions developer and see whether the start and end dates of the subscription change with them being held and reactivated as if they do then my plugin would automatically refactor the issues and give access to in your case 5, as they would already have March in their Access_products meta, and then if the start date changed on reactivation it would add September, and the next 3 would be added as they were published. I will post here once I have checked this out.

  2. I am looking for a similar solution. Where four issues are released a year.

    I would like it that if a person subscribes, after the 1st issue is released, they only get charged only for the next three ( or if two issues have passed, for next two issues, and if 3 issues have passed, they get billed only for the final one) and once the end of that years subscription is up, they automatically get invoiced for the full.

    Can your plugin do this, or is it possible to adapt. If so, what would the costs be.

Leave a Reply

Your email address will not be published. Required fields are marked *