Hi,
Guidance for developing the plugin yourself:
You can create a small HikaShop system plugin that hooks into the cron to automatically update user groups based on order totals. Here's the approach:
1. Create Joomla user groups for each tier (Bronze/Silver/Gold) and HikaShop discounts linked to each group
2. Create a system plugin (group "hikashop") that implements the `onHikashopCronTrigger` event. This event is called every time the HikaShop cron runs. In your plugin, run a SQL query like:
function onHikashopCronTrigger(&$messages) {
// Define your tiers: group_id => minimum turnover
$tiers = array(
5 => 1000, // Gold group: 1000+ EUR
4 => 200, // Silver group: 200+ EUR
3 => 100, // Bronze group: 100+ EUR
);
$db = JFactory::getDBO();
// Get cumulative order totals per user
$db->setQuery('SELECT order_user_id, SUM(order_full_price) as total
FROM #__hikashop_order
WHERE order_type = "sale"
AND order_status IN ("confirmed","shipped","delivered")
GROUP BY order_user_id');
$users = $db->loadObjectList();
foreach($users as $user) {
// Find the matching tier
foreach($tiers as $groupId => $minAmount) {
if($user->total >= $minAmount) {
// Get the Joomla user ID from the HikaShop user
$db->setQuery('SELECT user_cms_id FROM #__hikashop_user WHERE user_id = ' . (int)$user->order_user_id);
$cmsId = $db->loadResult();
if(!empty($cmsId)) {
// Add user to the tier group (if not already in it)
$db->setQuery('INSERT IGNORE INTO #__user_usergroup_map (user_id, group_id) VALUES (' . (int)$cmsId . ', ' . (int)$groupId . ')');
$db->execute();
}
break; // Assign only the highest matching tier
}
}
}
return true;
}The code can be adapted of course. That's just a simple example to get you started if you're a developer.
3. You'll also want to remove users from higher tier groups if they don't qualify anymore (e.g. if you want tiers to be exclusive).
4. For the discounts, go to HikaShop > Marketing > Discounts and create one discount per tier with the percentage and the access level restriction set to the corresponding Joomla group. See:
www.hikashop.com/support/documentation/2...iscount-listing.html
You can refer to the HikaShop developer documentation for creating plugins:
www.hikashop.com/support/documentation/6...r-documentation.html
If you'd prefer us to develop this for you instead, please contact us via the contact form on our website (
www.hikashop.com/support/contact-us.html
) with the details of your thresholds, discount percentages and other details. For example: Do you want the tier discount to activate immediately after a purchase (the cron solution is simpler, but will incur some delay) ? what are order statuses to be taken into account ? is there a time limit to take orders into account ? Should this be limited to only non distributor customers or all users ? etc
And we'll provide you with a quote.