PluginProbe ʕ •ᴥ•ʔ
WooCommerce Square / 5.4.2
WooCommerce Square v5.4.2
5.4.2 5.4.1 5.4.0 trunk 1.0.25 1.0.26 1.0.27 1.0.28 1.0.29 1.0.30 1.0.31 1.0.32 1.0.33 1.0.34 1.0.35 1.0.36 1.0.37 1.0.38 2.0.0 2.0.1 2.0.2 2.0.3 2.0.4 2.0.5 2.0.6 2.0.7 2.0.8 2.1.0 2.1.1 2.1.2 2.1.3 2.1.4 2.1.5 2.1.6 2.2.0 2.2.1 2.2.2 2.2.3 2.2.4 2.2.5 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 2.4.0 2.4.1 2.5.0 2.5.1 2.5.2 2.5.3 2.6.0 2.7.0 2.8.0 2.9.0 2.9.1 3.0.0 3.0.1 3.0.2 3.0.3 3.1.0 3.2.0 3.3.0 3.4.0 3.4.1 3.4.2 3.5.0 3.6.0 3.6.1 3.7.0 3.7.1 3.8.0 3.8.1 3.8.2 3.8.3 3.9.0 4.0.0 4.1.0 4.2.0 4.2.1 4.2.2 4.2.3 4.3.0 4.3.1 4.3.2 4.4.0 4.4.1 4.4.2 4.5.0 4.5.1 4.5.2 4.6.0 4.6.1 4.6.2 4.6.3 4.6.4 4.7.0 4.7.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.1 4.8.2 4.8.3 4.8.4 4.8.5 4.8.6 4.8.7 4.8.8 4.9.0 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 4.9.6 4.9.7 4.9.8 4.9.9 5.0.0 5.0.1 5.1.0 5.1.1 5.1.2 5.2.0 5.3.0 5.3.1 5.3.2 5.3.3
woocommerce-square / includes / WC_Payments_Compatibility.php
woocommerce-square / includes Last commit date
API 4 months ago Admin 1 day ago Emails 1 year ago Framework 1 day ago Gateway 2 months ago Handlers 1 day ago Internal 1 month ago Sync 4 weeks ago Utilities 1 month ago AJAX.php 2 years ago API.php 2 months ago Admin.php 2 months ago Coupons.php 4 months ago Functions.php 3 years ago Gateway.php 3 months ago Lifecycle.php 2 years ago Plugin.php 1 month ago Settings.php 4 months ago WC_Order_Square.php 2 years ago WC_Payments_Compatibility.php 1 year ago
WC_Payments_Compatibility.php
78 lines
1 <?php
2 /**
3 * Class for WooPayments compatibility.
4 */
5
6 namespace WooCommerce\Square;
7
8 use WooCommerce\Square\Handlers\Product;
9
10 /**
11 * WC_Payments_Compatibility Class
12 *
13 * @version 4.7.3
14 */
15 class WC_Payments_Compatibility {
16
17 /**
18 * Initialize the WooPayments Compatibility class.
19 *
20 * @since 4.7.3
21 */
22 public function init() {
23 add_filter( 'wcpay_payment_request_is_product_supported', array( $this, 'wcpay_is_product_supported' ), 10, 2 );
24 add_filter( 'wcpay_woopay_button_is_product_supported', array( $this, 'wcpay_is_product_supported' ), 10, 2 );
25 add_filter( 'wcpay_payment_request_is_cart_supported', array( $this, 'wcpay_is_product_supported' ), 10, 2 );
26 add_filter( 'wcpay_platform_checkout_button_are_cart_items_supported', array( $this, 'platform_checkout_button_are_cart_items_supported' ) );
27 }
28
29 /**
30 * Filter whether to display express pay buttons on product pages.
31 *
32 * Runs on the `wcpay_payment_request_is_product_supported` and
33 * `wcpay_woopay_button_is_product_supported` filters.
34 *
35 * @since 4.7.3
36 *
37 * @param bool $is_supported Whether express pay buttons are supported on product pages.
38 * @param \WC_Product $product The product object.
39 *
40 * @return bool Modified support status.
41 */
42 public function wcpay_is_product_supported( $is_supported, $product ) {
43 if ( Product::is_gift_card( $product ) ) {
44 // Express pay buttons are not supported on product pages.
45 return false;
46 }
47
48 return $is_supported;
49 }
50
51 /**
52 * Filter whether to display WooPay express pay buttons on cart pages.
53 *
54 * Hide the express WooPay button on cart pages containing Square Gift Cards.
55 *
56 * Runs on the `wcpay_platform_checkout_button_are_cart_items_supported` filter.
57 *
58 * @param bool $is_supported Whether express WooPay buttons are supported on cart pages.
59 *
60 * @return bool Modified support status.
61 */
62 public function platform_checkout_button_are_cart_items_supported( $is_supported ) {
63 if ( ! WC()->cart ) {
64 return $is_supported;
65 }
66
67 foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {
68 $product = $cart_item['data'];
69
70 if ( Product::is_gift_card( $product ) ) {
71 return false;
72 }
73 }
74
75 return $is_supported;
76 }
77 }
78