| 1 |
<?php |
| 2 |
/** |
| 3 |
* Cashfree functions |
| 4 |
*/ |
| 5 |
|
| 6 |
defined( 'ABSPATH' ) || exit; |
| 7 |
|
| 8 |
function wc_get_cashfree_template( $template_name, $args = array(), $template_path = '' ) { |
| 9 |
wc_get_template( $template_name, $args, $template_path, WC_CASHFREE_DIR_PATH . 'templates/' ); |
| 10 |
} |
| 11 |
|
| 12 |
/** |
| 13 |
* Register the script and inject parameters. |
| 14 |
* |
| 15 |
* @param string $handle Script handle the data will be attached to. |
| 16 |
* @param array|null $params Parameters injected. |
| 17 |
*/ |
| 18 |
function wc_cashfree_script( $handle, $params = null ) { |
| 19 |
$script = ( include 'wc-cashfree-scripts.php' )[ $handle ]; |
| 20 |
wp_enqueue_script( $handle, $script['src'], $script['deps'], $script['version'], true ); |
| 21 |
|
| 22 |
if ( null !== $params ) { |
| 23 |
wp_localize_script( $handle, str_replace( '-', '_', $handle ) . '_params', $params ); |
| 24 |
} |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* Register and load wc-cashfree script. |
| 29 |
* |
| 30 |
* @param array $settings Gateway settings. |
| 31 |
*/ |
| 32 |
function wc_cashfree_js( $settings ) { |
| 33 |
wc_cashfree_script('wc-cashfree-checkout-js'); |
| 34 |
wc_cashfree_script('wc-cashfree-checkout'); |
| 35 |
} |
| 36 |
|