Seems you have installed Ebizmarts Magemonkey extension.
This extension works only with Magento Newsletter module. So Magemonkey extension calls server when your customer subscribed or unsubcsribed on your site. No cron jobs, no sync, only newsletter events.
All additional events required custom coding.
Do I need to set Customer Fields Mapping?
yes sure. Here is example...
Magento field accept only:
- fname - $customer->getFirstname();
- lname - $customer->getLastname();
- gender
- dob
- billing_address
- shipping_address
- telephone
- company
- group_id
or any customer attribute
$customer->getData(strtolower(CUTSOMER_ATTRIBUTE))
In Mailchimp account navigate to Lists > [Select your list] > Settings > List fields and |MERGE| tags
Mailchimp field in Magento should match to Put this tag in you content field
Is it possible to create subscribers when the customer is creating an
order?
yes, you need to extend magemonkey module and add new event
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Event/etc/events.xsd">
<event name="sales_model_service_quote_submit_success">
<observer name="quote_to_order_success" instance="Vendor\Module\Observer\SalesQuoteSubmitSuccess" />
</event>
</config>
Vendor/Module/Observer/SalesQuoteSubmitSuccess.php
namespace Vendor\Module\Observer;
use Magento\Framework\Event\ObserverInterface;
use Magento\Framework\Event\Observer;
class SalesQuoteSubmitSuccess implements ObserverInterface {
/**
* @var \Ebizmarts\MageMonkey\Helper\Data
*/
protected $_helper;
/**
* @var \Ebizmarts\MageMonkey\Model\Api
*/
protected $_api = null;
/**
* @param \Ebizmarts\MageMonkey\Helper\Data $helper
* @param \Ebizmarts\MageMonkey\Model\Api $api
*/
public function __construct(
\Ebizmarts\MageMonkey\Helper\Data $helper,
\Ebizmarts\MageMonkey\Model\Api $api
) {
$this->_helper = $helper;
$this->_api = $api;
}
/**
* @param Observer $observer
* @return $this
*/
public function execute(Observer $observer) {
$quote = $observer->getEvent()->getQuote();
$customer = $quote->getCustomer();
$mergeVars = $this->_helper->getMergeVars($customer);
$api = $this->_api;
if ($this->_helper->isDoubleOptInEnabled($customer->getStoreId())) {
$status = 'pending';
} else {
$status = 'subscribed';
}
if ($mergeVars) {
$data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => $mergeVars];
} else {
$data = ['list_id' => $this->_helper->getDefaultList(), 'email_address' => $customer->getEmail(), 'email_type' => 'html', 'status' => $status, 'merge_fields' => ['EMAIL'=>$customer->getEmail()]];
}
try {
$emailHash = md5(strtolower($customer->getEmail()));
$return = $api->getMember($this->_helper->getDefaultList(), $emailHash);
if (!isset($return->id)) {
$return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));
}
} catch (\Exception $e) {
$this->_helper->log($e->getMessage());
}
return $this;
}
}
How to sync my subscribers with my MailChimp account.
you need to add new cron job and walk through all customers.
Use this to check the customer
$emailHash = md5(strtolower($customer->getEmail()));
$return = $api->getMember($this->_helper->getDefaultList(), $emailHash);
and this to send customer data to server
$return = $api->listCreateMember($this->_helper->getDefaultList(), json_encode($data));