mirror of
https://github.com/woocommerce/woocommerce-paypal-payments.git
synced 2025-09-06 18:16:38 +08:00
Merge pull request #1536 from woocommerce/PCP-1871-one-page-checkout-causes-mini-cart-not-showing-the-pp-button-on-certain-pages
One-page checkout causes mini cart not showing the PP button on certain pages (1871)
This commit is contained in:
commit
02de8ada7f
2 changed files with 40 additions and 9 deletions
|
@ -373,6 +373,8 @@ class SmartButton implements SmartButtonInterface {
|
|||
);
|
||||
}
|
||||
|
||||
$this->sanitize_woocommerce_filters();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1591,4 +1593,34 @@ class SmartButton implements SmartButtonInterface {
|
|||
|
||||
return absint( $wp->query_vars['order-pay'] );
|
||||
}
|
||||
|
||||
/**
|
||||
* Sanitize woocommerce filter on unexpected states.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
private function sanitize_woocommerce_filters(): void {
|
||||
|
||||
add_filter(
|
||||
'woocommerce_widget_cart_is_hidden',
|
||||
/**
|
||||
* Sometimes external plugins like "woocommerce-one-page-checkout" set the $value to null, handle that case here.
|
||||
* Here we also disable the mini-cart on cart-block and checkout-block pages where our buttons aren't supported yet.
|
||||
*
|
||||
* @psalm-suppress MissingClosureParamType
|
||||
*/
|
||||
function ( $value ) {
|
||||
if ( null === $value ) {
|
||||
if ( is_product() ) {
|
||||
return false;
|
||||
}
|
||||
return in_array( $this->context(), array( 'cart', 'checkout', 'cart-block', 'checkout-block' ), true );
|
||||
}
|
||||
return in_array( $this->context(), array( 'cart-block', 'checkout-block' ), true ) ? true : $value;
|
||||
},
|
||||
11
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue