クラス
ChangeActions
Amazon change actions JS
ソース ソース
ファイル: src/Components/AmazonChangeActions/ChangeActions.php
class ChangeActions { const WCEXAAP_CHANGE_ACTIONS_JS_SLUG = 'wcexaap-amazon-change-actions'; /** * AmazonPay module instance * * @var AmazonPay */ private $module; /** * Sets `$module` member var * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param AmazonPay $module */ public function __construct(AmazonPay $module) { $this->module = $module; } /** * Enqueues Amazon checkout JS and bind change actions * * @author Evan D Shaw <evandanielshaw@gmail.com> * @param string $checkoutSessionId * @param array $changeAddressIds * @param array $changePaymentMethodIds * @return void */ public function load($checkoutSessionId, $changeAddressIds, $changePaymentMethodIds = []) { wp_enqueue_script( Checkout::AMAZON_CHECKOUT_JS_SLUG, $this->module->getActingOpts()['amzjsurl'] . '/checkout.js', [], WCEXAAP_VERSION, false ); wp_enqueue_script( self::WCEXAAP_CHANGE_ACTIONS_JS_SLUG, WCEXAAP_PLUGIN_URL . '/dist/amazonChangeActions.js', [Checkout::AMAZON_CHECKOUT_JS_SLUG], WCEXAAP_VERSION, true ); wp_localize_script( self::WCEXAAP_CHANGE_ACTIONS_JS_SLUG, AmazonPay::L10N, array_merge( $this->module->getScriptInjectionVariables(), [ 'changeAddressIds' => $changeAddressIds, 'changePaymentMethodIds' => $changePaymentMethodIds, 'checkoutSessionId' => $checkoutSessionId, ] ) ); } }
- __construct — Sets $module member var
- load — Enqueues Amazon checkout JS and bind change actions