Exemple #1
0
 /**
  * Create the new notification email.
  * 
  * @param Member $customer
  * @param Order $order
  * @param String $from
  * @param String $to
  * @param String $subject
  * @param String $body
  * @param String $bounceHandlerURL
  * @param String $cc
  * @param String $bcc
  */
 public function __construct(Member $customer, Order $order, $from = null, $to = null, $subject = null, $body = null, $bounceHandlerURL = null, $cc = null, $bcc = null)
 {
     $siteConfig = ShopConfig::get()->first();
     if ($siteConfig->NotificationTo) {
         $this->to = $siteConfig->NotificationTo;
     }
     if ($siteConfig->NotificationSubject) {
         $this->subject = $siteConfig->NotificationSubject . ' - Order #' . $order->ID;
     }
     if ($siteConfig->NotificationBody) {
         $this->body = $siteConfig->NotificationBody;
     }
     if ($customer->Email) {
         $this->from = $customer->Email;
     } elseif (Email::getAdminEmail()) {
         $this->from = Email::getAdminEmail();
     } else {
         $this->from = 'no-reply@' . $_SERVER['HTTP_HOST'];
     }
     $this->signature = '';
     $adminLink = Director::absoluteURL('/admin/shop/');
     //Get css for Email by reading css file and put css inline for emogrification
     $this->setTemplate('Order_NotificationEmail');
     if (file_exists(Director::getAbsFile($this->ThemeDir() . '/css/ShopEmail.css'))) {
         $css = file_get_contents(Director::getAbsFile($this->ThemeDir() . '/css/ShopEmail.css'));
     } else {
         $css = file_get_contents(Director::getAbsFile('swipestripe/css/ShopEmail.css'));
     }
     $this->populateTemplate(array('Message' => $this->Body(), 'Order' => $order, 'Customer' => $customer, 'InlineCSS' => "<style>{$css}</style>", 'Signature' => $this->signature, 'AdminLink' => $adminLink));
     parent::__construct($from, null, $subject, $body, $bounceHandlerURL, $cc, $bcc);
 }
 public function CountriesForm()
 {
     $shopConfig = ShopConfig::get()->First();
     $fields = new FieldList($rootTab = new TabSet("Root", $tabMain = new Tab('Shipping', new HiddenField('ShopConfigSection', null, 'Countries'), new GridField('ShippingCountries', 'Shipping Countries', $shopConfig->ShippingCountries(), GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldFilterHeader')->removeComponentsByType('GridFieldAddExistingAutocompleter'))), new Tab('Billing', new GridField('BillingCountries', 'Billing Countries', $shopConfig->BillingCountries(), GridFieldConfig_RecordEditor::create()->removeComponentsByType('GridFieldFilterHeader')->removeComponentsByType('GridFieldAddExistingAutocompleter')))));
     $actions = new FieldList();
     $form = new Form($this, 'EditForm', $fields, $actions);
     $form->setTemplate('ShopAdminSettings_EditForm');
     $form->setAttribute('data-pjax-fragment', 'CurrentForm');
     $form->addExtraClass('cms-content cms-edit-form center ss-tabset');
     if ($form->Fields()->hasTabset()) {
         $form->Fields()->findOrMakeTab('Root')->setTemplate('CMSTabSet');
     }
     $form->setFormAction(Controller::join_links($this->Link($this->sanitiseClassName($this->modelClass)), 'Countries/CountriesForm'));
     $form->loadDataFrom($shopConfig);
     return $form;
 }
Exemple #3
0
 public function saveAttributeSettings($data, $form)
 {
     //Hack for LeftAndMain::getRecord()
     self::$tree_class = 'ShopConfig';
     $config = ShopConfig::get()->First();
     $form->saveInto($config);
     $config->write();
     $form->sessionMessage('Saved Attribute Settings', 'good');
     $controller = $this;
     $responseNegotiator = new PjaxResponseNegotiator(array('CurrentForm' => function () use(&$controller) {
         //return $controller->renderWith('ShopAdminSettings_Content');
         return $controller->AttributeSettingsForm()->forTemplate();
     }, 'Content' => function () use(&$controller) {
         //return $controller->renderWith($controller->getTemplatesWithSuffix('_Content'));
     }, 'Breadcrumbs' => function () use(&$controller) {
         return $controller->renderWith('CMSBreadcrumbs');
     }, 'default' => function () use(&$controller) {
         return $controller->renderWith($controller->getViewer('show'));
     }), $this->response);
     return $responseNegotiator->respond($this->getRequest());
 }
Exemple #4
0
 public static function current_shop_config()
 {
     //TODO: lazy load this
     return ShopConfig::get()->First();
 }