You are here

public function MailchimpEcommerceUbercartSyncOrders::_submitForm in Mailchimp E-Commerce 8

Processes data sync to Mailchimp.

Syncing data to Mailchimp is specific to the shopping cart integration. You should implement this function in your integration to process the data sync.

Overrides MailchimpEcommerceSyncOrders::_submitForm

File

modules/mailchimp_ecommerce_ubercart/src/Form/MailchimpEcommerceUbercartSyncOrders.php, line 21

Class

MailchimpEcommerceUbercartSyncOrders

Namespace

Drupal\mailchimp_ecommerce_ubercart\Form

Code

public function _submitForm($form, $form_state) {
  if (!empty($form_state
    ->getValue('sync_orders'))) {
    $batch = [
      'title' => t('Adding orders to Mailchimp'),
      'operations' => [],
    ];

    // TODO Replace this with a get all uber orders

    //$query = \Drupal::entityQuery('commerce_order');

    //$result = $query->execute();
    if (!empty($result)) {
      $order_ids = array_keys($result);
      $batch['operations'][] = [
        '\\Drupal\\mailchimp_ecommerce_ubercart\\BatchSyncOrders::syncOrders',
        [
          $order_ids,
        ],
      ];
    }
    batch_set($batch);
  }
}