Add Buyers to Joomla Groups for VirtueMart
Typical use cases are:
- Automatically add buyers to Joomla groups, which enables them access to certain parts of the site (e.g. club membership)
- 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.