-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Woo
committed
Jun 4, 2024
1 parent
a079134
commit 0e20c86
Showing
9 changed files
with
593 additions
and
160 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
includes/compatibility/modules/class-wc-min-max-quantities-paypal-compatibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
/** | ||
* WC_Min_Max_Quantities_PayPal_Compatibility class | ||
* | ||
* @package Woo Min Max Quantities | ||
* @since 4.3.2 | ||
*/ | ||
|
||
// Exit if accessed directly. | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* PayPal Compatibility. | ||
* | ||
* @version 4.3.2 | ||
*/ | ||
class WC_Min_Max_Quantities_PayPal_Compatibility { | ||
|
||
// Hide smart buttons in product pages when Min or Max qty/value are set. | ||
public static function init() { | ||
add_filter( 'woocommerce_paypal_payments_product_supports_payment_request_button', array( __CLASS__, 'handle_smart_buttons' ), 10, 2 ); | ||
} | ||
|
||
/** | ||
* Hide smart buttons in product pages when Min or Max qty/value are set. | ||
* | ||
* @param bool $is_supported | ||
* @param WC_Product $product | ||
* | ||
* @return bool | ||
*/ | ||
public static function handle_smart_buttons( $is_supported, $product ) { | ||
// If the smart button is not supported by some other plugin, respect that. | ||
if ( ! $is_supported ) { | ||
return $is_supported; | ||
} | ||
|
||
$mmq_instance = WC_Min_Max_Quantities::get_instance(); | ||
return $mmq_instance->can_display_express_checkout( $product ); | ||
} | ||
} | ||
|
||
WC_Min_Max_Quantities_PayPal_Compatibility::init(); |
59 changes: 59 additions & 0 deletions
59
includes/compatibility/modules/class-wc-min-max-quantities-stripe-compatibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
<?php | ||
/** | ||
* WC_Min_Max_Quantities_Stripe_Compatibility class | ||
* | ||
* @package Woo Min Max Quantities | ||
* @since 4.3.2 | ||
*/ | ||
|
||
// Exit if accessed directly. | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* Stripe Compatibility. | ||
* | ||
* @version 4.3.2 | ||
*/ | ||
class WC_Min_Max_Quantities_Stripe_Compatibility { | ||
|
||
// Hide smart buttons in product pages when Min or Max qty/value are set. | ||
public static function init() { | ||
add_filter( 'wc_stripe_hide_payment_request_on_product_page', array( __CLASS__, 'handle_express_checkout_buttons' ), 10, 2 ); | ||
} | ||
|
||
/** | ||
* Hide express checkout buttons in product pages when Min or Max qty/value are set. | ||
* | ||
* @param bool $hide | ||
* @param WP_Post $post | ||
* | ||
* @return bool | ||
*/ | ||
public static function handle_express_checkout_buttons( $hide, $post = null ) { | ||
// If the button is already hidden by some other plugin, respect that. | ||
if ( $hide ) { | ||
return $hide; | ||
} | ||
|
||
if ( is_null( $post ) ) { | ||
global $post; | ||
} | ||
|
||
if ( ! is_object( $post ) || empty( $post->ID ) ) { | ||
return $hide; | ||
} | ||
|
||
$product = wc_get_product( $post->ID ); | ||
if ( $product && is_a( $product, 'WC_Product' ) ) { | ||
$mmq_instance = WC_Min_Max_Quantities::get_instance(); | ||
$hide = ! $mmq_instance->can_display_express_checkout( $product ); // the filter needs true for hiding the button. | ||
return $hide; | ||
} | ||
|
||
return $hide; | ||
} | ||
} | ||
|
||
WC_Min_Max_Quantities_Stripe_Compatibility::init(); |
46 changes: 46 additions & 0 deletions
46
includes/compatibility/modules/class-wc-min-max-quantities-wc-payments-compatibility.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<?php | ||
/** | ||
* WC_Min_Max_Quantities_WC_Payments_Compatibility class | ||
* | ||
* @package Woo Min Max Quantities | ||
* @since 4.3.2 | ||
*/ | ||
|
||
// Exit if accessed directly. | ||
if ( ! defined( 'ABSPATH' ) ) { | ||
exit; | ||
} | ||
|
||
/** | ||
* WC_Payments Compatibility. | ||
* | ||
* @version 4.3.2 | ||
*/ | ||
class WC_Min_Max_Quantities_WC_Payments_Compatibility { | ||
|
||
public static function init() { | ||
// Hide express checkout buttons in product pages when Min or Max qty/value are set. | ||
add_filter( 'wcpay_payment_request_is_product_supported', array( __CLASS__, 'handle_express_checkout_buttons' ), 10, 2 ); | ||
add_filter( 'wcpay_woopay_button_is_product_supported', array( __CLASS__, 'handle_express_checkout_buttons' ), 10, 2 ); | ||
} | ||
|
||
/** | ||
* Hide express checkout buttons in product pages when Min or Max qty/value are set. | ||
* | ||
* @param bool $is_supported | ||
* @param WC_Product $product | ||
* | ||
* @return bool | ||
*/ | ||
public static function handle_express_checkout_buttons( $is_supported, $product ) { | ||
// If the smart button is not supported by some other plugin, respect that. | ||
if ( ! $is_supported ) { | ||
return $is_supported; | ||
} | ||
|
||
$mmq_instance = WC_Min_Max_Quantities::get_instance(); | ||
return $mmq_instance->can_display_express_checkout( $product ); | ||
} | ||
} | ||
|
||
WC_Min_Max_Quantities_WC_Payments_Compatibility::init(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.