mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-05 08:59:14 +08:00
Fix Smart Buttons on Elementor checkout
This commit is contained in:
parent
0cc4e1f9ce
commit
709871820f
4 changed files with 81 additions and 40 deletions
|
@ -15,6 +15,7 @@ use WooCommerce\PayPalCommerce\Vendor\Interop\Container\ServiceProviderInterface
|
|||
use WooCommerce\PayPalCommerce\Vendor\Psr\Container\ContainerInterface;
|
||||
use WooCommerce\PayPalCommerce\Compat\Assets\CompatAssets;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Exception\NotFoundException;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Helper\CartCheckoutDetector;
|
||||
use WooCommerce\PayPalCommerce\WcGateway\Settings\Settings;
|
||||
|
||||
/**
|
||||
|
@ -54,6 +55,7 @@ class CompatModule implements ModuleInterface {
|
|||
$this->migrate_smart_button_settings( $c );
|
||||
|
||||
$this->fix_page_builders();
|
||||
$this->set_elementor_checkout_context();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -329,4 +331,32 @@ class CompatModule implements ModuleInterface {
|
|||
$parent = $theme->parent();
|
||||
return ( $parent && $parent->get( 'Name' ) === 'Divi' );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the context for the Elementor checkout page.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
protected function set_elementor_checkout_context(): void {
|
||||
add_action(
|
||||
'wp',
|
||||
function() {
|
||||
$page_id = get_the_ID();
|
||||
if ( $page_id ) {
|
||||
if ( CartCheckoutDetector::has_elementor_checkout( $page_id ) ) {
|
||||
add_filter(
|
||||
'woocommerce_paypal_payments_context',
|
||||
function ( $context ): string {
|
||||
// Default context.
|
||||
if ( 'mini-cart' === $context ) {
|
||||
return 'checkout';
|
||||
}
|
||||
return $context;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue