Larship Hooks a beautiful way to add you extra actions to events fired, also filtering data passed or returned, for example :
- On subscription creation call an external API,
- On Save User Data Sync it with other CRM
- on Deleting Object send email to …
- and many more cases required for your business.
Hook Actions:
let’s assume you want to send email on subscriptions cancellation then on your plugin service provider add this to your register() function :
\Actions::add_action('pre_cancel_subscription', [YourClass::class, 'send_email'], 10);
10 shows the priority of executing hook, you need to make sure that priority is unique for hook actions
and then add in your hook Class the function
public send_email( $user, $plan){ .... }
Available Actions:
Payment\Braintree\resources\views\checkout.blade.php \Actions::do_action(‘pre_braintree_checkout_form’,$gateway)
Payment\PayPal\resources\views\subscription-checkout.blade.php
Before Showing PayPal Checkout Form : \Actions::do_action(‘pre_paypal_checkout_form’,$gateway)
Payment\Stripe\resources\views\card.blade.php
Before Showing PayPal Checkout Form : \Actions::do_action(‘pre_stripe_checkout_form’,$gateway)
Subscriptions\Classes\Subscription.php
Before Creating Subscription Customer : \Actions::do_action(‘pre_create_customer’, $this, $user, $parameters);
After Creating Subscription Customer : \Actions::do_action(‘post_create_customer’, $this, $user, $response);
Before Updating Subscription Customer : \Actions::do_action(‘pre_update_customer’, $this, $user, $parameters);
After Updating Subscription Customer : \Actions::do_action(‘post_update_customer’, $this, $response, $user);
Before Deleting Subscription Customer : \Actions::do_action(‘pre_delete_customer’, $this, $user, $parameters);
After Deleting Subscription Customer : \Actions::do_action(‘post_delete_customer’, $this, $response, $user);
Before Creating Subscription : \Actions::do_action(‘post_create_subscription’,$subscription);
Before Swapping Subscription :\Actions::do_action(‘pre_swap_subscription’, $user, $plan);
After Swapping Subscription :\Actions::do_action(‘post_swap_subscription’, $subscription);
After Cancelling Subscription :\Actions::do_action(‘pre_cancel_subscription’, $user, $plan);
Before Cancelling Subscription : \Actions::do_action(‘post_cancel_subscription’, $plan_subscription);
Before Creating Plan :\Actions::do_action(‘pre_create_plan’, $plan, $this->gateway);
After Creating Plan : \Actions::do_action(‘post_create_plan’, $plan, $this->gateway);
Before Updating Plan : \Actions::do_action(‘pre_update_plan’, $plan, $this->gateway);
After Updating Plan :\Actions::do_action(‘post_update_plan’, $plan, $this->gateway);
Before Fetching Plan : \Actions::do_action(‘pre_fetch_plan’, $plan, $this->gateway);
After Fetching Plan :\Actions::do_action(‘post_fetch_plan’, $plan, $this->gateway);
Before Deleting Plan : \Actions::do_action(‘pre_delete_plan’, $plan, $this->gateway);
After Deleting Plan : \Actions::do_action(‘post_delete_plan’, $plan, $this->gateway);
Before Creating Invoice :\Actions::do_action(‘pre_create_invoice’, $plan, $user, $this->gateway);
After Creating Invoice : \Actions::do_action(‘post_create_invoice’, $plan, $user, $this->gateway);
Before Paying Invoice : \Actions::do_action(‘pre_pay_invoice’, $invoiceReference, $this->gateway);
After paying Invoice : \Actions::do_action(‘post_pay_invoice’, $invoiceReference, $this->gateway);
Before Checking Subscription : \Actions::do_action(‘pre_subscription_check’, $this, $plan, $user);
Subscriptions\Models\Subscription.php
Before Cacelling Subscription : \Actions::do_action(‘pre_subscription_marked_as_cancelled’, $this);
Subscriptions\resources\views\partials\member_dashboard.blade.php
Showing User Profile Tabs : \Actions::do_action(‘user_profile_tabs’,user(),$active_tab)
Showing User Profile Contents :\Actions::do_action(‘user_profile_tabs_content’,user(),$active_tab)
Subscriptions\resources\views\subscription\checkout.blade.php
Before Form checkout : \Actions::do_action(‘pre_checkout_form’,$plan,$gateway)
Subscriptions\resources\views\subscription\pricing.blade.php
Before showing pricing table : \Actions::do_action(‘pre_pricing_table’,$product)
Available Filters:
Corals\modules\Referral\Classes\Referral.php
$actions = \Filters::do_filter(‘referral_action’,$actions);
$action_parameters = \Filters::do_filter(‘referral_program_action_parameters’, $action_parameters, $action, $this);
\Subscriptions\Classes\Subscription.php
$parameters = \Filters::do_filter(‘create_customer_parameters’, $parameters, $user, $this->gateway);
$parameters = \Filters::do_filter(‘update_customer_parameters’, $parameters, $user, $this->gateway);
$parameters = \Filters::do_filter(‘delete_customer_parameters’, $parameters, $user, $this->gateway);
$parameters = \Filters::do_filter(‘create_subscription_parameters’, $parameters, $user, $plan, $this->gateway);
$parameters = \Filters::do_filter(‘swap_subscription_parameters’, $parameters, $user, $plan, $product_subscription, $this->gateway);
$parameters = \Filters::do_filter(‘cancel_subscription_parameters’, $parameters, $user, $plan_subscription, $this->gateway);
$parameters = \Filters::do_filter(‘create_plan_parameters’, $parameters, $plan, $this->gateway);
$parameters = \Filters::do_filter(‘update_plan_parameters’, $parameters, $plan, $this->gateway);
$parameters = \Filters::do_filter(‘fetch_plan_parameters’, $parameters, $plan, $this->gateway);
$data = \Filters::do_filter(‘fetch_plan_response’, $data, $plan, $this->gateway);
$parameters = \Filters::do_filter(‘delete_plan_parameters’, $parameters, $plan, $this->gateway);
$attributes = \Filters::do_filter(‘create_invoice_parameters’, $attributes, $plan, $user, $this->gateway);
$parameters = \Filters::do_filter(‘pay_invoice_parameters’, $parameters, $this->gateway);
\Subscriptions\Models\Subscription.php
end_date = \Filters::do_filter(‘subscription_cancellation_end_date’, $end_date, $this);