Add Buyers to Joomla Groups Plugin for VirtueMart 2
With this VirtueMart 2 plugin, all buyers of a product can be automatically added to or removed from a Joomla user group or a VirtueMart shopper group.
Typical use cases are:
- Automatically add buyers to Joomla groups, which enables them access to certain parts of the site
- Make certain products in VirtueMart only available to buyers of another product
- Give previous buyers of a certain product different prices for future purchases (by adding them to a shopper group that has better prices in VirtueMart)
How the plugin works
Assume the shop owner wants each buyer of Product A to be added to the "Gold Buyers" VirtueMart shopper group and added to the "Author" Joomla user group. As soon as the purchase is completed, the buyer will be added to those groups. But if the order is refunded or cancelled for some reason later on, the user is removed again from these groups (unless he already has been a member of the groups before the purchase).
To achieve this with my plugin, the shop owner first needs to set up a custom field definition (once), which defines the list of order statuses that indicate a successful purchase.
Then he can assign a custom field of the type just created to "Product A" and select to which VirtueMart shopper groups or Joomla user groups the buyer should be added or removed.
Whenever a user now buys Product A and the order is confirmed, the user is removed from and added to the chosen groups (in that order, so if you configure the custom field to remove from and add to the same group, the user will be removed first and then added again). If the order is later cancelled or refunded, the actions by the plugin are also reverted (i.e. if the user was added to a group, he is removed again). The plugin stores whether the user has already been a member before the purchase, so when the order is refunded or cancelled the user is not removed again in that case.
Download the plugin file and install it just like any other Joomla plugin.
Configuration & How the plugin works
The assignment of the Joomla or VirtueMart groups to selected products is done via custom fields.
First, set up a Custom Field ("Products" -> "Custom Fields"). This needs to be done only once and will be re-used by all products later on:
- Create a new field (the green + button in the top right corner)
- Select "Plug-ins" as Custom Field Type
- Add a Title for the field (it will not be displayed to the buyer, but it will be used by the administrator when adding the custom field to a product)
- Select "Add Buyers to Joomla Groups for Virtuemart" as the plugin
- Select which order statuses indicate a successful purchase (multi-selection is possible using Ctrl+Click). If an order's status is changed to such a value, the user is added/removed to/from the particular groups selected in the product's custom field (see below).
Now you can add this custom field to any product you like:
- Open the product in the VirtueMart backend, go to the "Custom Fields" tab and add the field you just created (the Title you selected in the custom field setup above). You can now select the Joomla and Virtuemart groups for the product, where buyers should be automatically added to or removed from upon purchase.
This plugin is licenced unter the GNU GPLv3. You have to pay to download the plugin, but by this you automatically obtain all the rights and duties that the GPL gives you. All future upgrades are included (i.e. there is no timelimit on updates). Support is provided in the forums as far as my time allows, but I cannot guarantee proper support.
2013-09-28: Version 1.0 (Initial release)