Add feature switch for woo commerce list sync
[MAILPOET-1732]
This commit is contained in:
committed by
M. Shull
parent
9d7707b98f
commit
daca92097c
@ -57,7 +57,9 @@ class Changelog {
|
|||||||
$this->setupNewInstallation();
|
$this->setupNewInstallation();
|
||||||
$this->checkWelcomeWizard();
|
$this->checkWelcomeWizard();
|
||||||
}
|
}
|
||||||
$this->checkWooCommerceListImportPage();
|
if ($this->settings->get('woo_commerce_list_sync_enabled')) {
|
||||||
|
$this->checkWooCommerceListImportPage();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function checkMp2Migration($version) {
|
private function checkMp2Migration($version) {
|
||||||
|
@ -408,6 +408,9 @@ class Menu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function wooCommerceListImport() {
|
function wooCommerceListImport() {
|
||||||
|
if (!$this->settings->get('woo_commerce_list_sync_enabled')) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if ((bool)(defined('DOING_AJAX') && DOING_AJAX)) return;
|
if ((bool)(defined('DOING_AJAX') && DOING_AJAX)) return;
|
||||||
$data = [
|
$data = [
|
||||||
'finish_wizard_url' => $this->wp->adminUrl('admin.php?page=' . self::MAIN_PAGE_SLUG),
|
'finish_wizard_url' => $this->wp->adminUrl('admin.php?page=' . self::MAIN_PAGE_SLUG),
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
namespace MailPoet\Cron;
|
namespace MailPoet\Cron;
|
||||||
|
|
||||||
use MailPoet\Cron\Workers\WorkersFactory;
|
use MailPoet\Cron\Workers\WorkersFactory;
|
||||||
|
use MailPoet\Settings\SettingsController;
|
||||||
|
|
||||||
if (!defined('ABSPATH')) exit;
|
if (!defined('ABSPATH')) exit;
|
||||||
|
|
||||||
@ -29,7 +30,10 @@ class Daemon {
|
|||||||
$this->executeBounceWorker();
|
$this->executeBounceWorker();
|
||||||
$this->executeExportFilesCleanupWorker();
|
$this->executeExportFilesCleanupWorker();
|
||||||
$this->executeInactiveSubscribersWorker();
|
$this->executeInactiveSubscribersWorker();
|
||||||
$this->executeWooCommerceSyncWorker();
|
$settings = new SettingsController();
|
||||||
|
if ($settings->get('woo_commerce_list_sync_enabled')) {
|
||||||
|
$this->executeWooCommerceSyncWorker();
|
||||||
|
}
|
||||||
} catch (\Exception $e) {
|
} catch (\Exception $e) {
|
||||||
CronHelper::saveDaemonLastError($e->getMessage());
|
CronHelper::saveDaemonLastError($e->getMessage());
|
||||||
}
|
}
|
||||||
|
@ -24,6 +24,9 @@ class WooCommerce {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function synchronizeRegisteredCustomer($wp_user_id, $current_filter = null) {
|
function synchronizeRegisteredCustomer($wp_user_id, $current_filter = null) {
|
||||||
|
if (!$this->settings->get('woo_commerce_list_sync_enabled')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$wc_segment = Segment::getWooCommerceSegment();
|
$wc_segment = Segment::getWooCommerceSegment();
|
||||||
|
|
||||||
if ($wc_segment === false) return;
|
if ($wc_segment === false) return;
|
||||||
@ -72,6 +75,9 @@ class WooCommerce {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function synchronizeGuestCustomer($order_id, $current_filter = null) {
|
function synchronizeGuestCustomer($order_id, $current_filter = null) {
|
||||||
|
if (!$this->settings->get('woo_commerce_list_sync_enabled')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
$wc_order = $this->wp->getPost($order_id);
|
$wc_order = $this->wp->getPost($order_id);
|
||||||
$wc_segment = Segment::getWooCommerceSegment();
|
$wc_segment = Segment::getWooCommerceSegment();
|
||||||
|
|
||||||
|
@ -98,4 +98,8 @@ class Settings {
|
|||||||
function withWooCommerceListImportPageDisplayed($was_shown) {
|
function withWooCommerceListImportPageDisplayed($was_shown) {
|
||||||
$this->settings->set('woocommerce.import_screen_displayed', $was_shown ? 1 : 0);
|
$this->settings->set('woocommerce.import_screen_displayed', $was_shown ? 1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function withWooCommerceListSyncEnabled() {
|
||||||
|
$this->settings->set('woo_commerce_list_sync_enabled', 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -22,6 +22,7 @@ class WooCommerceCustomerListCest {
|
|||||||
$this->product_factory = new WooCommerceProduct($I);
|
$this->product_factory = new WooCommerceProduct($I);
|
||||||
$settings_factory = new Settings();
|
$settings_factory = new Settings();
|
||||||
$settings_factory->withWooCommerceListImportPageDisplayed(true);
|
$settings_factory->withWooCommerceListImportPageDisplayed(true);
|
||||||
|
$settings_factory->withWooCommerceListSyncEnabled();
|
||||||
$customer_factory = new WooCommerceCustomer($I);
|
$customer_factory = new WooCommerceCustomer($I);
|
||||||
$customer_factory->deleteAll();
|
$customer_factory->deleteAll();
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,9 @@ class WooCommerceListImportPageCest {
|
|||||||
// Cleanup
|
// Cleanup
|
||||||
$this->customer_factory->deleteAll();
|
$this->customer_factory->deleteAll();
|
||||||
$this->order_factory->deleteAll();
|
$this->order_factory->deleteAll();
|
||||||
|
// Feature switch
|
||||||
|
$settings_factory = new Settings();
|
||||||
|
$settings_factory->withWooCommerceListSyncEnabled();
|
||||||
}
|
}
|
||||||
|
|
||||||
function importListPageImportTest(\AcceptanceTester $I) {
|
function importListPageImportTest(\AcceptanceTester $I) {
|
||||||
|
@ -16,6 +16,7 @@ class DaemonTest extends \MailPoetTest {
|
|||||||
public function _before() {
|
public function _before() {
|
||||||
parent::_before();
|
parent::_before();
|
||||||
$this->settings = new SettingsController();
|
$this->settings = new SettingsController();
|
||||||
|
$this->settings->set('woo_commerce_list_sync_enabled', 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
function testItCanExecuteWorkers() {
|
function testItCanExecuteWorkers() {
|
||||||
|
@ -27,6 +27,7 @@ class WooCommerceTest extends \MailPoetTest {
|
|||||||
function _before() {
|
function _before() {
|
||||||
$this->woocommerce_segment = ContainerWrapper::getInstance()->get(WooCommerceSegment::class);
|
$this->woocommerce_segment = ContainerWrapper::getInstance()->get(WooCommerceSegment::class);
|
||||||
$this->settings = ContainerWrapper::getInstance()->get(SettingsController::class);
|
$this->settings = ContainerWrapper::getInstance()->get(SettingsController::class);
|
||||||
|
$this->settings->set('woo_commerce_list_sync_enabled', 1);
|
||||||
$this->cleanData();
|
$this->cleanData();
|
||||||
$this->addCustomerRole();
|
$this->addCustomerRole();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user