rebase on oct-10-2023
This commit is contained in:
@@ -37,13 +37,12 @@ class Api {
|
||||
public function __construct( PaymentMethodRegistry $payment_method_registry, AssetDataRegistry $asset_registry ) {
|
||||
$this->payment_method_registry = $payment_method_registry;
|
||||
$this->asset_registry = $asset_registry;
|
||||
$this->init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initialize class features.
|
||||
*/
|
||||
protected function init() {
|
||||
public function init() {
|
||||
add_action( 'init', array( $this->payment_method_registry, 'initialize' ), 5 );
|
||||
add_filter( 'woocommerce_blocks_register_script_dependencies', array( $this, 'add_payment_method_script_dependencies' ), 10, 2 );
|
||||
add_action( 'woocommerce_blocks_checkout_enqueue_data', array( $this, 'add_payment_method_script_data' ) );
|
||||
@@ -80,13 +79,13 @@ class Api {
|
||||
* Add payment method data to Asset Registry.
|
||||
*/
|
||||
public function add_payment_method_script_data() {
|
||||
// Enqueue the order of enabled gateways as `paymentGatewaySortOrder`.
|
||||
if ( ! $this->asset_registry->exists( 'paymentGatewaySortOrder' ) ) {
|
||||
// Enqueue the order of enabled gateways.
|
||||
if ( ! $this->asset_registry->exists( 'paymentMethodSortOrder' ) ) {
|
||||
// We use payment_gateways() here to get the sort order of all enabled gateways. Some may be
|
||||
// programmatically disabled later on, but we still need to know where the enabled ones are in the list.
|
||||
$payment_gateways = WC()->payment_gateways->payment_gateways();
|
||||
$enabled_gateways = array_filter( $payment_gateways, array( $this, 'is_payment_gateway_enabled' ) );
|
||||
$this->asset_registry->add( 'paymentGatewaySortOrder', array_keys( $enabled_gateways ) );
|
||||
$this->asset_registry->add( 'paymentMethodSortOrder', array_keys( $enabled_gateways ) );
|
||||
}
|
||||
|
||||
// Enqueue all registered gateway data (settings/config etc).
|
||||
|
||||
Reference in New Issue
Block a user