Restriction of purchase if already in download area.

  • Posts: 38
  • Thank you received: 0
5 years 3 months ago #309444

-- HikaShop version -- : 4.2.1
-- Joomla version -- : 3.9.10
-- PHP version -- : 7.2.20
-- Browser(s) name and version -- : Chrome

I want the order to fail if the customer already has a copy of the file in their download directory. I need it to show a message like 'you have already purchased this ebook' or whatever I need it to say.

Is there any way of doing this within the restrictions of the existing software or is it a bespoke programming item?

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

  • Posts: 12953
  • Thank you received: 1778
5 years 3 months ago #309468

Hello,

There's actually no option to do that, so the best solution will either be to :
- Develop a plugin or edit the code of your payment plugins, to prevent the order creation if he is not supposed to make any purchase.

OR

- Set the "User group after purchase" option of your product configuration page to a custom user group
- Go to your payment configuration pages and restrict your payment method to every groups but that new one.

Kind regards,
Mohamed Thelji.

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

  • Posts: 38
  • Thank you received: 0
5 years 3 months ago #309511

Mohamed Thelji wrote: Hello,

There's actually no option to do that, so the best solution will either be to :
- Develop a plugin or edit the code of your payment plugins, to prevent the order creation if he is not supposed to make any purchase.


It needs to happen at the click to add to cart stage. If it gets to the payment plugin, then it's going to be too late.

Mohamed Thelji wrote: - Set the "User group after purchase" option of your product configuration page to a custom user group
- Go to your payment configuration pages and restrict your payment method to every groups but that new one.


With a million ebooks - I don't think that's even a viable suggestion.

If anyone has managed to resolve this issue please let me know. Thanks in advance.

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

  • Posts: 12953
  • Thank you received: 1778
5 years 3 months ago #309512

Hello,

I'm sorry if my suggestions were not viable solution for your issue, it wasn't specified that the error message should have bean displayed just after clicking on the add to cart button.

A good solution can be to directly develop a plugin based on the "onBeforeCartSave(&$element,&$do)" trigger, and cancel the add to cart action if your user already purchased that product and display your error message.

For more information about that trigger, you can check our developer documentation :

This method will be called by HikaShop before the cart is saved, when a product is added, removed, modified, when a shipping or payment method is selected, etc. In the object $element, you can have an attribute cart_products which is an array of products to be added/modified. You can use the variable $do to cancel the save.

www.hikashop.com/support/documentation/6...umentation.html#cart

Kind regards,
Mohamed Thelji

Last edit: 5 years 3 months ago by Mohamed Thelji.

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

  • Posts: 38
  • Thank you received: 0
5 years 3 months ago #309550

Hi Mohamed

I think I've got a workaround for this by allowing the download to be available on the product page. Then altering the label as in picture.

It would be useful to disable the product link below it. Is there a simple bit of code I can add to do that?

Attachments:

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

  • Posts: 82863
  • Thank you received: 13372
  • MODERATOR
5 years 3 months ago #309557

Hi,

I'm not sure what you mean ? You want to disable the link to the download file there ?
In that case, you could just add such CSS:
#hikashop_product_files_main .hikashop_product_file_link{ display:none;}

The following user(s) said Thank You: lesk

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

  • Posts: 38
  • Thank you received: 0
5 years 3 months ago #309589

Thank you, that's fine. :)

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

Time to create page: 0.092 seconds
Powered by Kunena Forum