|
/ Documentation /Developer Hooks & Events/ suredonation_enqueue_form_frontend_scripts Action Hook

suredonation_enqueue_form_frontend_scripts Action Hook

Overview

The suredonation_enqueue_form_frontend_scripts action fires while a donation form is being rendered on the front end, right after SureDonation enqueues its shared form stylesheet and script. Its primary purpose is to let payment-gateway extensions enqueue their own front-end assets (for example, loading the PayPal SDK for a specific form).

Hook Signature

do_action( 'suredonation_enqueue_form_frontend_scripts', $form_id, $form_content );

Parameters

$form_id _(int)_ – The donation form post ID being rendered.

$form_content _(string)_ – The form’s raw block markup ($form->post_content). You can parse this to decide whether your assets are needed.

Usage

add_action( 'suredonation_enqueue_form_frontend_scripts', 'your_custom_function', 10, 2 );

function your_custom_function( $form_id, $form_content ) {

    // Your custom logic here.

}

Example

add_action( 'suredonation_enqueue_form_frontend_scripts', 'mysite_enqueue_gateway_sdk', 10, 2 );

function mysite_enqueue_gateway_sdk( $form_id, $form_content ) {

    if ( has_block( 'suredonation/payment', $form_content ) ) {

        wp_enqueue_script(

            'mysite-gateway',

            'https://cdn.example.com/gateway.js',

            [],

            '1.0.0',

            true

        );

    }

}

Notes

Related Hooks

  • suredonation_available_payment_methods
  • sd-payment-success _(JS event)_
Was this doc helpful?
What went wrong?

We don't respond to the article feedback, we use it to improve our support content.

Need help? Contact Support
Table of Contents
Scroll to Top