Onboarding.php
5 months ago
OnboardingHelper.php
1 year ago
OnboardingIndustries.php
2 years ago
OnboardingJetpack.php
3 years ago
OnboardingMailchimp.php
3 years ago
OnboardingProducts.php
3 years ago
OnboardingProfile.php
1 year ago
OnboardingSetupWizard.php
1 year ago
OnboardingSync.php
2 years ago
OnboardingMailchimp.php
54 lines
| 1 | <?php |
| 2 | /** |
| 3 | * WooCommerce Onboarding Mailchimp |
| 4 | */ |
| 5 | |
| 6 | namespace Automattic\WooCommerce\Internal\Admin\Onboarding; |
| 7 | |
| 8 | use Automattic\WooCommerce\Internal\Admin\Schedulers\MailchimpScheduler; |
| 9 | |
| 10 | /** |
| 11 | * Logic around updating Mailchimp during onboarding. |
| 12 | */ |
| 13 | class OnboardingMailchimp { |
| 14 | /** |
| 15 | * Class instance. |
| 16 | * |
| 17 | * @var OnboardingMailchimp instance |
| 18 | */ |
| 19 | private static $instance = null; |
| 20 | |
| 21 | /** |
| 22 | * Get class instance. |
| 23 | */ |
| 24 | final public static function instance() { |
| 25 | if ( ! static::$instance ) { |
| 26 | static::$instance = new static(); |
| 27 | } |
| 28 | return static::$instance; |
| 29 | } |
| 30 | |
| 31 | /** |
| 32 | * Init. |
| 33 | */ |
| 34 | public function init() { |
| 35 | add_action( 'woocommerce_onboarding_profile_data_updated', array( $this, 'on_profile_data_updated' ), 10, 2 ); |
| 36 | } |
| 37 | |
| 38 | /** |
| 39 | * Reset MailchimpScheduler if profile data is being updated with a new email. |
| 40 | * |
| 41 | * @param array $existing_data Existing option data. |
| 42 | * @param array $updating_data Updating option data. |
| 43 | */ |
| 44 | public function on_profile_data_updated( $existing_data, $updating_data ) { |
| 45 | if ( |
| 46 | isset( $existing_data['store_email'] ) && |
| 47 | isset( $updating_data['store_email'] ) && |
| 48 | $existing_data['store_email'] !== $updating_data['store_email'] |
| 49 | ) { |
| 50 | MailchimpScheduler::reset(); |
| 51 | } |
| 52 | } |
| 53 | } |
| 54 |