option_name, null ); } /** * Retrieves the current plugin account. * * @return string The current plugin account. */ public function currentAccountId() { return \SureCart::account()->id ?? ''; } /** * Flush the rewrite rules on account change. * * @return boolean */ public function maybeStartSync() { $current_account_id = $this->currentAccountId(); $stored_account_id = $this->getStoredAccount(); // there is no current account id, or the stored account id is the same as the current account id. if ( empty( $current_account_id ) || $current_account_id === $stored_account_id ) { return false; } return $this->startSync(); } /** * Flushes the rewrite rules and updates the stored account. * * @return boolean */ public function startSync() { $this->sync(); return update_option( $this->option_name, $this->currentAccountId(), false ); } /** * Sync the store data. * * @return mixed */ public function sync() { if ( \SureCart::sync()->products()->isActive() ) { return false; } return \SureCart::sync()->products()->dispatch(); } }