WP-Members Memberships for WooCommerce version 0.6.0 has been released. This is primarily a bug fix release, but it includes a couple of steps towards the full 1.0.0 version as well.
First, the bug fix.
There was an issue with processing autocompleted orders and a few other processing elements where the plugin relied on determining if the order contained a product that had at least one linked membership.
The problem was that the post meta containing linked memberships was checked, and then PHP’s “explode()” function converted it to an array before any “if” conditions were checked. That meant while the “if” conditions were looking for a “false” value if there were no linked memberships, in reality the variable contained an empty array (instead of a “false” boolean). So even if there were no linked membership, the system thought there was.
This isn’t a problem for sites that are only selling membership-linked products. And I presume that’s most of the current users right now. But where it does manifest itself is where there are other products without a membership link and those orders should not be automatically marked as completed.
The fix was a simple one, but I took the opportunity to condense some of the logic and make the entire process a little tighter AND more flexible, which leads us to the next element in the update:
Some new action hooks
Up until now, the plugin doesn’t have any hooks yet. We haven’t hit any processes where they have been absolutely necessary, but I’ve been looking at how users are using the plugin and keeping a look out for future customization needs.
I’ve had a couple of users come to me with some minor customization needs, and those were do-able without actually needing hooks in the plugin. BUT… some action hooks in certain locations would definitely simplify those processes (which I expect will become more common), so this update includes two new action hooks:
- wpmem_wc_autocomplete – this fires if the order has a linked membership and will be auto-completed. If the order will be auto-completed, this fires and passes the $order_id.
- wpmem_wc_order_completed_set_membership – this action fires when a membership is being set for a product in an order. In many cases, these will all be singular items (and order with one product that has one linked membership). But these can be multiples – such as an order with multiple products each with multiple memberships. So the action hook would fire for each membership that is being set in the process. It will pass the following (in order): $user_id, $membership (the WP-Members membership product being set), $product_id (the WC product), and $order_id.
Guest checkout in WooCommerce now optional
Previously, the plugin needed to have WooCommerce setting for guest checkout disabled. This is because the user needs to be a site user to have a membership assigned to them.
This update now makes this optional. If you do not disable guest checkout, the plugin will check the contents of the user’s cart. If the cart contains a product that has at least one linked membership, then guest checkout will automatically be disabled for that order.
So you have the option of disabling guest checkout altogether, OR, if you need it enabled for other non-member products, you can leave it enabled.
User Orders Tab
WP-Members 3.2.5 added a set of jQuery UI tabs in the user profile that has a set of hooks for customizing. So we make use of that here.
If you’re running WP-Members 3.2.5 or higher, this will add an “Orders” tab to the user profile containing a table of the user’s orders and a direct link to the order screen in WooCommerce.
As always, I hope these updates are useful for you, and if you have any trouble with the update (or notice something that isn’t right), definitely let me know!