getId()}", $item->toArray()); try { $this->mailchimp()->addPromoRule($this->store_id, $item->getAttachedPromoRule(), true); $response = $this->mailchimp()->addPromoCodeForRule($this->store_id, $item->getAttachedPromoRule(), $item, true); mailchimp_log('coupon_sync.success', "update promo rule :: #{$item->getCode()}"); return $response; } catch (MailChimp_WooCommerce_ServerError $e) { mailchimp_error('order_submit.error', mailchimp_error_trace($e, "update promo rule :: {$item->getCode()}")); return false; } catch (MailChimp_WooCommerce_Error $e) { mailchimp_error('order_submit.error', mailchimp_error_trace($e, "update promo rule :: {$item->getCode()}")); return false; } catch (Exception $e) { mailchimp_error('order_submit.error', mailchimp_error_trace($e, "update promo rule :: {$item->getCode()}")); return false; } } mailchimp_debug('coupon_sync', 'no coupon found', $item); return false; } /** * After the resources have been loaded and pushed */ protected function complete() { mailchimp_log('coupon_sync.completed', 'Done with the coupon sync.'); // add a timestamp for the orders sync completion $this->setResourceCompleteTime(); } }