Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Filter to Disable WooPay for Improved Compatibility #10468

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions changelog/update-9938
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Significance: minor
Type: add

New Filter: disable_woopay – Allows developers to conditionally disable WooPay based on custom logic, improving compatibility with themes and plugins.
23 changes: 23 additions & 0 deletions includes/class-wc-payment-gateway-wcpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -563,6 +563,7 @@ public function get_form_fields() {
*/
public function init_hooks() {
add_action( 'init', [ $this, 'maybe_update_properties_with_country' ] );
add_action( 'init', [ $this, 'disable_woopay' ] );
// Only add certain actions/filter if this is the main gateway (i.e. not split UPE).
if ( self::GATEWAY_ID === $this->id ) {
add_action( 'woocommerce_order_actions', [ $this, 'add_order_actions' ] );
Expand Down Expand Up @@ -4434,6 +4435,28 @@ private function upe_needs_redirection( $payment_methods ) {
return 1 === count( $payment_methods ) && 'card' !== $payment_methods[0];
}


/**
* Disable WooPay.
*
* This function disables WooPay by updating the option to 'no'
* once the 'disable_woopay' filter is called.
*
* @return boolean False, indicating WooPay is disabled.
*/
public function disable_woopay() {
// Filter: disable_woopay.
$disable = apply_filters( 'disable_woopay', true );

// disable WooPay by updating the option to 'no'.
if ( $disable ) {
$this->update_option( 'platform_checkout', 'no' );
}

return false;
}


/**
* Handles the shipping requirement for Afterpay payments.
*
Expand Down
Loading