Role expire support

Created on 25 July 2023, over 1 year ago
Updated 27 July 2023, over 1 year ago

Problem/Motivation

With Commece I want to sell a role for a limited time (subscribe) and once cancelled or not renewed the premium role needs to be removed.

Is it possible to achieve this with this module? It seems only commerce orders are there but not subriptions.

I foud module role expire with this issue
✨ Make Rules integration a sub-module, provide ECA integration Active so maybe provide support for this or allow commerce subscription status to be configured as condtion in ECA.

Does anyone can help how to manage subscription and assign role once the subscrption is active?

πŸ“Œ Task
Status

Fixed

Version

1.0

Component

Code

Created by

πŸ‡ΈπŸ‡°Slovakia coaston

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @coaston
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    I'm moving this into the ECA Commerce integration module.

    There might be a couple of options on how to resolve this:

    • If the subscription module dispatches an event when a subscription expires, then ECA can listen to that event and do the role assignment logic.
    • Otherwise, you could probably write a view which lists you all expired subscriptions, and then you could remove the role for each of those.
  • πŸ‡ΈπŸ‡°Slovakia coaston

    #jurgenhaas Thank you

    The idea with a view is quite good. I started but need help to finish it.

    1. Created a view with commerce subcription type
    2. Added filter to state active and trial
    3. Contextual filter to current user
    4. Display only 1 row

    So if user has multiple subscribtions for me it is good enough there is at least one active and if not the view result is blank so i would say my view is ready.

    Now i need to use ECA but not sure how to check if result of view has any result. If there is any - assign user with premium role. If the view is blank = remove premium role. I can comfigure cron but not sure about views.
    I have tried this example with no luck :
    View model

  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    That sample model is quite a good one. You can probably enhance it by using the condition to see how many items are in a list to see if the result is empty or not. There is also another example model at https://ecaguide.org/library/use%20case/eca_feature_demo/ which shows how to add or remove roles from users.

    Then, if the model doesn't work as expected, then the debugging techniques described in https://ecaguide.org/eca/debugging/ should help you to find out where it goes wrong.

  • πŸ‡ΈπŸ‡°Slovakia coaston

    Thank you. I was able to complete this with condition to check the count of rows. So now it seems it works as expected.

    Before I close this issue, just wondering if it is possible to limit users to only be able to register one account from the same IP address with ECA?

  • Status changed to Fixed over 1 year ago
  • πŸ‡©πŸ‡ͺGermany jurgenhaas Gottmadingen

    Thanks for your feedback.

    As for the second question, this qualifies for a new issue, but in the ECA queue. It then also helps other users find it when they ever come along to a similar question.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024