discount per user group

  • Posts: 35
  • Thank you received: 3
10 years 7 months ago #152894

-- url of the page with the problem -- : www.adelashoes.com/
-- HikaShop version -- : 2.3.0
-- Joomla version -- : 3.2.3
-- PHP version -- : 5.4.27
-- Browser(s) name and version -- : Firefox 28.x
-- Error-message(debug-mod must be tuned on) -- : Error_message

Hi all, new to Joomla, HikaShop and this forum.

No error message but new feature suggestion:
Allow discounts for specific groups of clients.

Implementation:
1. In user manager, create new user groups, named "Discount A", "Discount B", "Discount C".
Manually assign users to user groups depending on their VIP level or sales volume.
2. In HikaShop, create new discounts, named A (10 %), B, (5 %), C (3 %).
Activate all of these discounts.
3. Change the few lines of code in cart.php, discount.php, currency.php to join the users and discounts -- done.

Question:
I see these .php files in a /tmp/ directory from installation. However they do not seem to be used in production, and/or they are cached in between. However I have turned cache off in Joomla. Where am I supposed to look? (Specifically, this is an 1und1.de "Dual Basic" contract.)
Happy to see this as an official new HikaShop feature!

best regards

Klaus

Last edit: 10 years 7 months ago by hactic.

Please Log in or Create an account to join the conversation.

  • Posts: 35
  • Thank you received: 3
10 years 7 months ago #152897

Found the productive files -- they are all under /administrator/components/com_hikashop/classes/.

best regards

Klaus

Please Log in or Create an account to join the conversation.

  • Posts: 35
  • Thank you received: 3
10 years 7 months ago #152900

update:
The code sits in cart.php, currency.php (at two places), discount.php.
I named discounts and groups the same: "Discount A", "Discount B", "Discount C".
Then the codeneeds to join in additional tables usergroup and user_usergroup_map.
Sample:

// hactic.com discount 1/4 begin
$user = JFactory::getUser();
$userId = $user->get( 'id' );
// $filters = array('discount_type=\'coupon\'','discount_published=1','discount_auto_load=1');
$filters = array('discount_type=\'coupon\'','discount_published=1','discount_auto_load=1',
'( d.discount_code=ug.title )',
'( ugm.user_id='.$userId.' )',
'( ugm.group_id=ug.id )');
hikashop_addACLFilters($filters,'discount_access');
// $query = 'SELECT * FROM '.hikashop_table('discount').' WHERE '.implode(' AND ',$filters).' ORDER BY discount_minimum_order DESC, discount_minimum_products DESC';
$query = 'SELECT * FROM '.hikashop_table('discount').' d, '.hikashop_table('usergroup', false).' ug,'.hikashop_table('user_usergroup_map', false).' ugm WHERE '.implode(' AND ',$filters).' ORDER BY discount_minimum_order DESC, discount_minimum_products DESC';
// hactic.com discount 1/4 end

best regards

Klaus

Please Log in or Create an account to join the conversation.

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
10 years 7 months ago #152909

Hi,

A more simple solution is to use HikaShop Business and configure the "access level" option of your discounts when you create/edit them so that you can restrict them to the user groups you want.
That way, no need to hack any files of HikaShop and you won't loose your changes when you update HikaShop since you won't have any code changes.

Last edit: 10 years 2 months ago by Xavier.
The following user(s) said Thank You: hactic

Please Log in or Create an account to join the conversation.

  • Posts: 35
  • Thank you received: 3
10 years 7 months ago #153122

Thanks for the answer. -- That is the correct way of thinking. I will definitely consider the commercial versions before I do another such hack that would always need to be patched into future versions. But coming from Java, it was nice to see how well-structured (your) php code can be -- something I will put trust in + will recommend further.

The following user(s) said Thank You: nicolas

Please Log in or Create an account to join the conversation.

  • Posts: 23
  • Thank you received: 0
10 years 2 months ago #171936

Hi Nicolas,
You said that this feature is available with commercial versions but I can't set the access level with my Essential edition.
And cannot find this feature in the comparison table www.hikashop.com/extensions/compare-versions.html
Thanks
François

Please Log in or Create an account to join the conversation.

  • Posts: 13201
  • Thank you received: 2322
10 years 2 months ago #171945

Hi,

Sorry, I just edited the message of Nicolas. It was a mistake the access level settings are only available in the business edition of HikaShop.

hikashop.com/extensions/upgrade-my-version.html

Please Log in or Create an account to join the conversation.

Time to create page: 0.077 seconds
Powered by Kunena Forum