Skip to content

Commit a19f2b0

Browse files
authored
Do not show the WooPay button on the product page when WC Bookings require confirmation (#7682)
1 parent 98b361f commit a19f2b0

File tree

2 files changed

+21
-7
lines changed

2 files changed

+21
-7
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Significance: patch
2+
Type: fix
3+
4+
Do not show the WooPay button on the product page when WC Bookings require confirmation

includes/class-wc-payments-woopay-button-handler.php

+17-7
Original file line numberDiff line numberDiff line change
@@ -634,6 +634,11 @@ private function is_product_supported() {
634634
$is_supported = false;
635635
}
636636

637+
// WC Bookings require confirmation products are not supported.
638+
if ( is_a( $product, 'WC_Product_Booking' ) && $product->get_requires_confirmation() ) {
639+
$is_supported = false;
640+
}
641+
637642
return apply_filters( 'wcpay_woopay_button_is_product_supported', $is_supported, $product );
638643
}
639644

@@ -647,14 +652,19 @@ private function is_product_supported() {
647652
private function has_allowed_items_in_cart() {
648653
$is_supported = true;
649654

655+
/**
656+
* Psalm throws an error here even though we check the class existence.
657+
*
658+
* @psalm-suppress UndefinedClass
659+
*/
650660
// We don't support pre-order products to be paid upon release.
651-
if (
652-
class_exists( 'WC_Pre_Orders_Cart' ) &&
653-
WC_Pre_Orders_Cart::cart_contains_pre_order() &&
654-
class_exists( 'WC_Pre_Orders_Product' ) &&
655-
WC_Pre_Orders_Product::product_is_charged_upon_release( WC_Pre_Orders_Cart::get_pre_order_product() )
656-
) {
657-
$is_supported = false;
661+
if ( class_exists( 'WC_Pre_Orders_Cart' ) && class_exists( 'WC_Pre_Orders_Product' ) ) {
662+
if (
663+
WC_Pre_Orders_Cart::cart_contains_pre_order() &&
664+
WC_Pre_Orders_Product::product_is_charged_upon_release( WC_Pre_Orders_Cart::get_pre_order_product() )
665+
) {
666+
$is_supported = false;
667+
}
658668
}
659669

660670
return apply_filters( 'wcpay_platform_checkout_button_are_cart_items_supported', $is_supported );

0 commit comments

Comments
 (0)