Add user to specific usergroup after purchase?

  • Posts: 60
  • Thank you received: 3
12 years 9 months ago #37322

Hello! I restrict certain aresas (video categories) of my site to users of specific groups. Namely those who pay for access to certain categories are added to that usergroup.

Is it possible to have someone buy a product in HikaShop and upon successful payment they are automatically added to that usergroup?

Thanks!

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 9 months ago #37463

Yes. In your products you can use the option "User group after purchase" for that. Note that this is only available in the Business edition.

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

  • Posts: 184
  • Thank you received: 4
12 years 4 months ago #56433

I have to do something really similar.

We sell subscriptions and normal products.
The customers can buy the products with very good prices but to do that they need to have a valid subscription.

So I can use the same method, when a customer buy a subscription, we can add a user to a specific "User group after purchase" and allow him to buy the normal product.

Considering the subscription is valid only for a specific period (one month, 6 month or one year), is there a way to automatically delete the user from the "User group after purchase" when the subscription is no more valid?
Or do I have to do it manually?

(At the moment I am using the Starter version 1.5.8 and i cannot verify it, I will probably buy the business version shortly because the product and the assistance is very good :laugh: )

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 4 months ago #56479

If you want to handle subscriptions (so that the access expires after a certain period), you should instead use our integration with Akeeba Subscriptions:
www.hikashop.com/en/support/documentatio...a-subscriptions.html

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

  • Posts: 184
  • Thank you received: 4
12 years 4 months ago #56683

I downloaded and tested the akeeba subscrition and the plug in, and as usual you suggestion is great! :)

I think there is a little error on the plug in.
It seems akkeba doesn't see the shipping fee

The order is 43.90 € (19.90 € for subscription and 24 € for shipping fee) and the amount on akeeba is only 19.90 €.




is it correct? or does the plug-in do it intentionally?

I have also another question, with the hikashop business edition I can add an user to a specific "User group after purchase" when they buy a subscription product.
Then I can allow the users to buy specific products only if they bought the subscription.

How could I automatically unsubscribe the user at the end of the subscription period?
Could akeeba subscritpion component do it?

Thank as usual for your great help.

Attachments:
Last edit: 12 years 4 months ago by Teto.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 4 months ago #56735

That's normal. If you have product A which is a normal HikaShop product and product B which is attached to a subscription level, and if you buy both of them in the same order, why should the shipping of the order, or the price of the product A be referenced in the subscription of the user in akeeba subscriptions ?
It's normal that only the price of the product B goes in the subscription.

What you want to do is to just use akeeba subscriptions options to add/remove groups to a user (you should look at their documentation for how to do that).
That "user group after purchase" option is not to be used for subscriptions but just for when you want to allow users access to a part of your website without time limit once they buy the product.

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

  • Posts: 184
  • Thank you received: 4
12 years 4 months ago #56852

First of all thanks of your answer :) , I understand your concern about the shipping fee, the reason of my question is because my case is a little bit different.

I sell subscriptions, these subscriptions include 2 bottles (product A and B ) for each month.
The subscriptions includes the shipping fee because the costs depend where and how we have to deliver the products.

In addition, for the customers who have a valid subscription, we sell the same products with a very low price but with a higher quantity (for example if you like the bottle A you received with the subscription, you can buy it with at least 6 bottles).

For this reason we have 2 needs:
1) we have to allow users to buy the normal products only if they have a valid subscription (I can do that with the "user group after purchase")
2) at the end of the subscription (generally 1 or 6 or 12 months) we have to unsubscribe the users so they cannot buy anymore the normal products until they buy another subscrition.

If I am not wrong you say that i can use the akeeba subscriptions to meet both the two needs.

Am I correct?
Do you have any suggestion for the shipping fee of the subscrition?

Last edit: 12 years 4 months ago by Teto.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 4 months ago #56877

Indeed, you should use Akeeba Subscriptions to add/remove the group of the user so that he can/can't access the products.

For the shipping, you would have to modify the code of the akeeba subscriptions plugin in order to also add the price of the shipping of the product in the subscription. It's not easy as all the prices need to be recalculated, the taxes need to be handled, etc but it's feasible.

The following user(s) said Thank You: Teto

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

  • Posts: 184
  • Thank you received: 4
12 years 4 months ago #58946

Dear Nicolas, finally I bought the business version.

In order to deny some products to some customer I used the access level (and akeeba subscriptions).
It works but this is not what I need.

In this way the customer cannot see the products. In my case I would like to show them the products but deny them the possibility to purchase them.
Instead of the "Add to Cart" button I would like to have a button to send them to the subscription page.

Is it possible?

Last edit: 12 years 4 months ago by Teto.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 4 months ago #58993

There is a possibility.

Instead of having the user group configured for the product, configure it for the price of the product and turn off the option "display add to cart button for free product" in the configuration of HikaShop.
That way, other users would be able to see the products but they wouldn't be able to buy it. They would see the text "free" instead of the price and the add to cart button. Then you can override that text and change to something else:
www.hikashop.com/en/download/languages.html#modify

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

  • Posts: 184
  • Thank you received: 4
12 years 4 months ago #59038

Thank you Nicolas

this already is a good solution.

Anyway considering that the price is a really good price and is valid only for the subscriber (we hope to gain more subscribers with this startegy), the best solution for us is:
- show anyway the price
- deny the add to cart button for the customer wihout a valid subscription
- instead of the add to cart button show a button with "Subscribe" linked to the "subscribe" page.

Do you think is possibile with a small costomization?
I also think this could be a great opportunity for all the person that propose subscriptions and should be a good idea to have this functionality in the standard version of hika, what do you think?

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 3 months ago #59090

Then you would have to not use the price ACLs in HikaShop.
Instead, edit the file "quantity" of the view "product" via Display->Views.
There, you can easily get the groups of the user via that code on Joomla 2.5:
$user =& JFactory::getUser();
$userGroups = JAccess::getGroupsByUser($user->id, true);

And then you can check yourself the group of the user and not display the add to cart button if he is not allowed:
if(in_array(13,$userGroups)) continue;

Here, 13 needs to be replaced with the id of the user group who can buy products.

All that code needs to go after the first <?php tag of the file.

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

  • Posts: 184
  • Thank you received: 4
12 years 3 months ago #59382

Hello Nicolas

I have some problem to do that.

I modifyed the code as you told me but it doesn't work fine.

<?php
$user =& JFactory::getUser();
$userGroups = JAccess::getGroupsByUser($user->id, true);
if(in_array(9,$userGroups)) continue;
/**
* @package HikaShop for Joomla!
* @version 1.5.8
* @author hikashop.com
* @copyright (C) 2010-2012 HIKARI SOFTWARE. All rights reserved.
* @license GNU/GPLv3 www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die('Restricted access');
?>
<?php
if(!empty($this->row->has_options)){
echo $this->cart->displayButton(JText::_('CHOOSE_OPTIONS'),'choose_options',$this->params,hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.$this->itemid),'window.location = \''.str_replace("'","\'",hikashop_completeLink('product&task=show&product_id='.$this->row->product_id.$this->itemid)).'\';return false;','');
}else{
$url = '';
if(empty($this->ajax)){
$this->ajax = 'return hikashopModifyQuantity(\''.$this->row->product_id.'\',field,1,0);';
}
if($this->row->product_sale_start || empty($this->element->main)){
$start_date = $this->row->product_sale_start;


Here you see the result on the frontend (see the attachment).



It lose all the styles and there is only one product instead of 3.

Did I something wrong?

Could you also indicate me the code I have to insert to show a button to direct the user to a specific link " www.madeinvino.com/index.php/abbonati "?

Thank you very much!

Attachments:
Last edit: 12 years 3 months ago by Teto.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 3 months ago #59439

It means that there is an error.
Please turn set the "error reporting" option of the joomla configuration to "maximum" and try again and you should see the error message. That will help us understand what's going on.

If you want a continue button there, just enter your URL in the "URL for continue button" option of the checkout tab of the configuration. The button will then be created automatically.

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

  • Posts: 184
  • Thank you received: 4
12 years 3 months ago #59528

the error is:

Fatal error: Cannot break/continue 1 level in /home/madeinvi/public_html/templates/madeinvino/html/com_hikashop/product/quantity.php on line 4

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 3 months ago #59573

Ah yes. It should be:
if(in_array(9,$userGroups)) return;

instead of :
if(in_array(9,$userGroups)) continue;

in my code.

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

  • Posts: 184
  • Thank you received: 4
12 years 3 months ago #59632

Great nicolas, it works!!!

regarding the button to direct the user to the subscription page.
I would like to show a button with a fix label (fro example "Subscribe") linked to a Joomla Menù (the subscription page).



this is the syntax I use i the joomla articles

<p><span style="font-size: 8pt;"><a class="art-button" href="index.php?option=com_content&view=category&layout=blog&id=9&Itemid=112">Abbonati subito!</a></span>
</p>

Do you think is possible?

Attachments:
Last edit: 12 years 3 months ago by Teto.

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

  • Posts: 82868
  • Thank you received: 13377
  • MODERATOR
12 years 3 months ago #59684

Ah yes, you can include your HTML at the end of the "listing" file of the "product" view of the front end via the menu Display->Views for that. It should definitely work.

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

  • Posts: 184
  • Thank you received: 4
12 years 3 months ago #59713

it works!!!!! :P

i'm becoming a PHP expert..... i'm joking i am really far from that... ;-) (

I added the code in the "quantity" file of the "product"


$user =& JFactory::getUser();
$userGroups = JAccess::getGroupsByUser($user->id, true);
if (!in_array(9,$userGroups)) {
?>
<p> <span style="font-size: 8pt;"><a class="art-button" href="index.php?option=com_content&view=category&layout=blog&id=9&Itemid=112">Solo per Abbonati</a></span> </p>
<?php
return;
}

Thank you nicolas, without your help it was impossible to find the solution.
I am really very happy of my choice (Hikashop Business)!

Attachments:
Last edit: 12 years 3 months ago by Teto.

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

Time to create page: 0.124 seconds
Powered by Kunena Forum