public static function addSubscriptions(Order $objOrder, $arrTokens)
 {
     $strEmail = $objOrder->getBillingAddress()->email;
     $objAddress = $objOrder->getShippingAddress() ?: $objOrder->getBillingAddress();
     $arrItems = $objOrder->getItems();
     $objSession = \Session::getInstance();
     if (!($intModule = $objSession->get('isotopeCheckoutModuleIdSubscriptions'))) {
         return true;
     }
     $objSession->remove('isotopeCheckoutModuleIdSubscriptions');
     $objModule = \ModuleModel::findByPk($intModule);
     foreach ($arrItems as $item) {
         switch ($objModule->iso_direct_checkout_product_mode) {
             case 'product_type':
                 $objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product_type', Standard::findAvailableByIdOrAlias($item->product_id)->type);
                 break;
             default:
                 $objFieldpalette = FieldPaletteModel::findBy('iso_direct_checkout_product', $item->product_id);
                 break;
         }
         if ($objFieldpalette !== null && $objFieldpalette->iso_addSubscription) {
             if ($objFieldpalette->iso_subscriptionArchive && (!$objFieldpalette->iso_addSubscriptionCheckbox || \Input::post('subscribeToProduct_' . $item->product_id))) {
                 $objSubscription = Subscription::findOneBy(array('email=?', 'pid=?', 'activation!=?', 'disable=?'), array($strEmail, $objFieldpalette->iso_subscriptionArchive, '', 1));
                 if (!$objSubscription) {
                     $objSubscription = new Subscription();
                 }
                 if ($objFieldpalette->iso_addActivation) {
                     $strToken = md5(uniqid(mt_rand(), true));
                     $objSubscription->disable = true;
                     $objSubscription->activation = $strToken;
                     if (($objNotification = Notification::findByPk($objFieldpalette->iso_activationNotification)) !== null) {
                         if ($objFieldpalette->iso_activationJumpTo && ($objPageRedirect = \PageModel::findByPk($objFieldpalette->iso_activationJumpTo)) !== null) {
                             $arrTokens['link'] = \Environment::get('url') . '/' . \Controller::generateFrontendUrl($objPageRedirect->row()) . '?token=' . $strToken;
                         }
                         $objNotification->send($arrTokens, $GLOBALS['TL_LANGUAGE']);
                     }
                 }
                 $arrAddressFields = \Config::get('iso_addressFields');
                 if ($arrAddressFields === null) {
                     $arrAddressFields = serialize(array_keys(static::getIsotopeAddressFields()));
                 }
                 foreach (deserialize($arrAddressFields, true) as $strName) {
                     $objSubscription->{$strName} = $objAddress->{$strName};
                 }
                 $objSubscription->email = $strEmail;
                 $objSubscription->pid = $objFieldpalette->iso_subscriptionArchive;
                 $objSubscription->tstamp = $objSubscription->dateAdded = time();
                 $objSubscription->quantity = \Input::post('quantity');
                 $objSubscription->order_id = $objOrder->id;
                 $objSubscription->save();
             }
         }
     }
     return true;
 }
Пример #2
0
 /**
  * Return a widget object based on a product attribute's properties
  * @param   string
  * @param   boolean
  * @return  string
  */
 protected function generateProductOptionWidget($strField, &$arrVariantOptions, &$arrAjaxOptions)
 {
     \Controller::loadDataContainer(ProductModel::getTable());
     $GLOBALS['TL_DCA'][ProductModel::getTable()]['fields']['gift_amount']['default'] = $GLOBALS['TL_DCA'][ProductModel::getTable()]['fields']['gift_amount']['default'] ?: Isotope::formatPrice($this->getPrice()->getAmount());
     return parent::generateProductOptionWidget($strField, $arrVariantOptions, $arrAjaxOptions);
 }
Пример #3
0
 /**
  * Find jumpTo page for current category scope
  *
  * @param \Isotope\Model\Product\Standard $objProduct
  *
  * @return \PageModel
  */
 protected function findJumpToPage($objProduct)
 {
     global $objPage;
     global $objIsotopeListPage;
     $productCategories = $objProduct->getCategories(true);
     $arrCategories = array();
     if ($this->iso_category_scope != 'current_category' && $this->iso_category_scope != '' && $objPage->alias != 'index') {
         $arrCategories = array_intersect($productCategories, $this->findCategories());
     }
     // If our current category scope does not match with any product category,
     // use the first allowed product category in the current root page
     if (empty($arrCategories)) {
         $arrCategories = $productCategories;
     }
     $arrCategories = Frontend::getPagesInCurrentRoot($arrCategories, \FrontendUser::getInstance());
     if (!empty($arrCategories) && ($objCategories = \PageModel::findMultipleByIds($arrCategories)) !== null) {
         $blnMoreThanOne = $objCategories->count() > 1;
         foreach ($objCategories as $objCategory) {
             if ($objCategory->alias == 'index' && $blnMoreThanOne) {
                 continue;
             }
             return $objCategory;
         }
     }
     return $objIsotopeListPage ?: $objPage;
 }