Subscription Triggers

  • Posts: 55
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
2 weeks 4 days ago #365124

Hi,
We've been using Hikashop/Serial for many years now, and finally started to look at subscriptions.

We have an existing, custom, plugin which communicates with a 3rd party system when an order is generated via the

onAfterOrderUpdate
trigger. This works well.

Now, we'd also like to pass some subscription info to the 3rd party system when a subscription is (a) created and also (b) renewed (which will be done automatically via the Paypal recurring payment plugin).

I have a plan created and assigned to a product using "Creation then Renewal". Within the
onAfterOrderUpdate
trigger, I took a look at the object returned by
'class.order'->loadFullOrder()
function but this doesn't appear to include any of the associated order's subscription data.

Is there a mechanism to obtain the subscription data (e.g. subscription Id, valid from/to datetime) from within the
onAfterOrderUpdate
trigger or perhaps a different trigger specifically for subscriptions? I saw
onCheckSubscription
but I suspect this is for a different use case?

If such a thing is possible, is it the same mechanism for both initial subscription creation AND automatic renewal (using "Creation then Renewal")?

Many thanks,
Oliver

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

  • Posts: 55
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
2 weeks 4 days ago #365125

Urg... Google doesn't appear to know about the specific HikaSerial Developer Documentation (here www.hikashop.com/support/documentation/1...erial-developer.html ).

I guess this is what I'm looking for?

Is there any documentation that explains the flow that calls these functions and the structure of the objects passed (e.g. $subscription)? I'm sure I can work it out through trial and error, but a more depth to the documentation would be great.

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

  • Posts: 55
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
2 weeks 4 days ago #365129

I now have a subscription plugin (loosely based on groupsubscriber) installed in Joomla. However, the triggers aren't called when I change the state of a subscription. I assume that's because I need to associate the plugin with the subscription plan, but I can't see where this is achieved.

The docs state:

Depending the plugins you're using for the plan, they can act differently depending the state of the subscription.
For example, the group subscriber will add the account into a specific Joomla group(s) when the subscription is active and will remove the account from the group(s) when it expires.


My plan has the groupsubscriber plan action configured by default (though I didn't select it anywhere) so I'm wondering if there's some magic sauce required to make *my* plugin appear as a plan action?

Any help on additional configuration steps would be greatly appreciated.

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

  • Posts: 26185
  • Thank you received: 4030
  • MODERATOR
2 weeks 3 days ago #365130

Hello,

Sorry for the late reply.

All HikaSerial plugins are loaded for HikaSubscription triggers, but the HikaSerialPlugin helper simplify the plugin by reducing the quantity of code that you need to write.
For exemple, the $type "subscriber" will handle all the integration for subscription.
Afterwards, the $name is important because it gives the link between the plugin (its name) and the configuration fields.
And, the $subscriptionConfig is only read when the $type is "subscriber" ; it's the settings that you want to add in the "action" tab for the plans.

You can take a look at the helper to see what function hikaserialPlugin contains (and can be override).
You'll see "onPlanActionsConfiguration" which handle the display of configuration in the plan form.
Or the function "onSubscriptionUpgrade" which handle the upgrade and redirect the calls to expiration/activation on the old and new subscription.

When you change the state of the subscription, the trigger "onBeforeSubscriptionUpdate" will be call.
The other triggers (onSubscriptionActivation, onSubscriptionExpiration) are called for specific modification of state.
There is no specific trigger called when a subscription is renewed ; but that's something that we will add in the future since we saw some needs for the community.

In order to better understand your issue ; we would need to understand what triggers you're using and the parameters you have set-up (plugin class name, first variables of the class).

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

  • Posts: 55
  • Thank you received: 2
  • Hikaserial Subscription Hikashop Business
2 weeks 3 days ago #365134

Hi Jerome,

Thanks for the reply - I'm making progress.

I now have a serial Plugin that's being invoked when I purchase a product with an attached subscription plan.

However! ;-)

An important part of our subscription relates to field data captured on the product line. When onSubscriptionActivation is called, I can see the subscription data (id, start/end dates/etc.) AND the complete order, along with the product(s) that were ordered and their captured data.

But we need to be able to link a subscription to a specific purchased product (and its data) - is this possible? We've looked over the structure and can't find anything that links a specific subscription to an order line.

Is that possible?

Thanks again for the help.

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

  • Posts: 26185
  • Thank you received: 4030
  • MODERATOR
2 weeks 3 days ago #365138

Hello,

You can load the "order_subscription" data ; manually, with a SQL query or by using the helpers (class subscription, function get ; under $subscription->orders).
There you will get the order_id and the order_product_id related to the specific subscription.
Thanks to the order_id and order_product_id, you will be able to get the order custom fields and the item custom fields.

Regards,


Jerome - Obsidev.com
HikaMarket & HikaSerial developer / HikaShop core dev team.

Also helping the HikaShop support team when having some time or couldn't sleep.
By the way, do not send me private message, use the "contact us" form instead.

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

Moderators: Obsidev
Time to create page: 0.062 seconds
Powered by Kunena Forum