-
Notifications
You must be signed in to change notification settings - Fork 207
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into fix/duplicate-emails
- Loading branch information
Showing
15 changed files
with
259 additions
and
121 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
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
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
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
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
63 changes: 63 additions & 0 deletions
63
includes/migrations/class-migrate-payment-request-data-to-express-checkout-data.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,63 @@ | ||
<?php | ||
/** | ||
* Class Migrate_Payment_Request_Data_To_Express_Checkout_Data | ||
*/ | ||
|
||
defined( 'ABSPATH' ) || exit; | ||
|
||
/** | ||
* Class Migrate_Payment_Request_Data_To_Express_Checkout_Data | ||
* | ||
* Migrates Payment Request settings data to Express Checkout settings data. | ||
* | ||
* @since 9.1.0 | ||
*/ | ||
class Migrate_Payment_Request_Data_To_Express_Checkout_Data { | ||
/** | ||
* Migrate_Payment_Request_Data_To_Express_Checkout_Data constructor. | ||
*/ | ||
public function __construct() { | ||
add_action( 'woocommerce_stripe_updated', [ $this, 'maybe_migrate' ] ); | ||
} | ||
|
||
/** | ||
* Only execute the migration if not applied yet. | ||
*/ | ||
public function maybe_migrate() { | ||
$stripe_gateway = $this->get_gateway(); | ||
|
||
$express_checkout_enabled = $stripe_gateway->get_option( 'express_checkout' ); | ||
|
||
if ( empty( $express_checkout_enabled ) ) { | ||
$this->migrate(); | ||
} | ||
} | ||
|
||
/** | ||
* Copies over Payment Request settings data to Express Checkout settings data. | ||
*/ | ||
private function migrate() { | ||
$stripe_gateway = $this->get_gateway(); | ||
|
||
$payment_request_enabled = $stripe_gateway->get_option( 'payment_request', 'no' ); | ||
$payment_request_button_type = $stripe_gateway->get_option( 'payment_request_button_type', 'default' ); | ||
$payment_request_button_theme = $stripe_gateway->get_option( 'payment_request_button_theme', 'dark' ); | ||
$payment_request_button_size = $stripe_gateway->get_option( 'payment_request_button_size', 'default' ); | ||
$payment_request_button_locations = $stripe_gateway->get_option( 'payment_request_button_locations', [ 'checkout' ] ); | ||
|
||
$stripe_gateway->update_option( 'express_checkout', $payment_request_enabled ); | ||
$stripe_gateway->update_option( 'express_checkout_button_type', $payment_request_button_type ); | ||
$stripe_gateway->update_option( 'express_checkout_button_theme', $payment_request_button_theme ); | ||
$stripe_gateway->update_option( 'express_checkout_button_size', $payment_request_button_size ); | ||
$stripe_gateway->update_option( 'express_checkout_button_locations', $payment_request_button_locations ); | ||
} | ||
|
||
/** | ||
* Returns the main Stripe payment gateways. | ||
* | ||
* @return WC_Stripe_Payment_Gateway | ||
*/ | ||
public function get_gateway() { | ||
return woocommerce_gateway_stripe()->get_main_stripe_gateway(); | ||
} | ||
} |
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
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.