mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-03 08:37:53 +08:00
Force cart and block-cart button loctions when AXO is active (3091)
This commit is contained in:
parent
2aeeb78a16
commit
41ac4197ee
6 changed files with 94 additions and 2 deletions
|
@ -13,7 +13,10 @@ use WooCommerce\PayPalCommerce\Axo\Assets\AxoManager;
|
|||
use WooCommerce\PayPalCommerce\Axo\Gateway\AxoGateway;
|
||||
use WooCommerce\PayPalCommerce\Axo\Helper\ApmApplies;
|
||||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\PayPalGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
return array(
|
||||
|
||||
|
@ -193,4 +196,32 @@ return array(
|
|||
|
||||
return '<div class="ppcp-notice ppcp-notice-warning"><p>' . $notice_content . '</p></div>';
|
||||
},
|
||||
|
||||
'axo.smart-button-location-notice' => static function ( ContainerInterface $container ) : string {
|
||||
$settings = $container->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
if ( $settings->has( 'axo_enabled' ) && $settings->get( 'axo_enabled' ) ) {
|
||||
$fastlane_settings_url = admin_url(
|
||||
sprintf(
|
||||
'admin.php?page=wc-settings&tab=checkout§ion=%1$s&ppcp-tab=%2$s#field-axo_heading',
|
||||
PayPalGateway::ID,
|
||||
CreditCardGateway::ID
|
||||
)
|
||||
);
|
||||
|
||||
$notice_content = sprintf(
|
||||
/* translators: %1$s: URL to the Checkout edit page. */
|
||||
__(
|
||||
'<span class="highlight">Important:</span> The <code>Cart</code> & <code>Classic Cart</code> <strong>Smart Button Locations</strong> cannot be disabled while <a href="%1$s">Fastlane</a> is active.',
|
||||
'woocommerce-paypal-payments'
|
||||
),
|
||||
esc_url( $fastlane_settings_url )
|
||||
);
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
||||
return '<div class="ppcp-notice"><p>' . $notice_content . '</p></div>';
|
||||
},
|
||||
);
|
||||
|
|
|
@ -197,7 +197,7 @@ class AxoManager {
|
|||
'CA' => WC()->countries->get_states( 'CA' ),
|
||||
),
|
||||
),
|
||||
'module_url' => untrailingslashit( $this->module_url ),
|
||||
'module_url' => untrailingslashit( $this->module_url ),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -24,6 +24,7 @@ use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
|||
use WooCommerce\PayPalCommerce\WcGateway\Gateway\CreditCardGateway;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\SettingsListener;
|
||||
|
||||
/**
|
||||
* Class AxoModule
|
||||
|
@ -108,6 +109,27 @@ class AxoModule implements ModuleInterface {
|
|||
}
|
||||
);
|
||||
|
||||
// Force 'cart-block' and 'cart' Smart Button locations in the settings.
|
||||
add_action(
|
||||
'admin_init',
|
||||
static function () use ( $c ) {
|
||||
$listener = $c->get( 'wcgateway.settings.listener' );
|
||||
assert( $listener instanceof SettingsListener );
|
||||
|
||||
$settings = $c->get( 'wcgateway.settings' );
|
||||
assert( $settings instanceof Settings );
|
||||
|
||||
$listener->filter_settings(
|
||||
$settings->has( 'axo_enabled' ) && $settings->get( 'axo_enabled' ),
|
||||
'smart_button_locations',
|
||||
function( array $existing_setting_value ) {
|
||||
$axo_forced_locations = array( 'cart-block', 'cart' );
|
||||
return array_unique( array_merge( $existing_setting_value, $axo_forced_locations ) );
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
|
||||
add_action(
|
||||
'init',
|
||||
function () use ( $c, $module ) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue