StoreHandler.php in Mailchimp E-Commerce 8
File
src/StoreHandler.php
View source
<?php
namespace Drupal\mailchimp_ecommerce;
class StoreHandler implements StoreHandlerInterface {
public function getStore($store_id) {
$store = NULL;
try {
$mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
$store = $mc_ecommerce
->getStore($store_id);
} catch (\Exception $e) {
if ($e
->getCode() == 404) {
}
else {
mailchimp_ecommerce_log_error_message('Unable to get store: ' . $e
->getMessage());
drupal_set_message($e
->getMessage(), 'error');
}
}
return $store;
}
public function addStore($store_id, $store, $platform) {
try {
$mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
$parameters = [
'platform' => $platform,
];
$mc_store = $mc_ecommerce
->addStore($store_id, $store, $parameters);
\Drupal::moduleHandler()
->invokeAll('mailchimp_ecommerce_add_store', [
$mc_store,
]);
} catch (\Exception $e) {
mailchimp_ecommerce_log_error_message('Unable to add a new store: ' . $e
->getMessage());
drupal_set_message($e
->getMessage(), 'error');
}
}
public function updateStore($store_id, $name, $currency_code, $platform) {
try {
$mc_ecommerce = mailchimp_get_api_object('MailchimpEcommerce');
$parameters = [
'platform' => $platform,
];
$mc_ecommerce
->updateStore($store_id, $name, $currency_code, $parameters);
} catch (\Exception $e) {
mailchimp_ecommerce_log_error_message('Unable to update a store: ' . $e
->getMessage());
drupal_set_message($e
->getMessage(), 'error');
}
}
}