示例#1
0
 /**
  * Initialize environment (language, objPage) for a given order
  *
  * @param Order  $objOrder
  * @param string $strLanguage
  */
 public static function loadOrderEnvironment(Order $objOrder, $strLanguage = null)
 {
     global $objPage;
     $strLanguage = $strLanguage ?: $objOrder->language;
     // Load page configuration
     if ($objOrder->pageId > 0 && (null === $objPage || $objPage->id != $objOrder->pageId)) {
         $objPage = \PageModel::findWithDetails($objOrder->pageId);
         $objPage = static::loadPageConfig($objPage);
     }
     // Set the current system to the language when the user placed the order.
     // This will result in correct e-mails and payment description.
     $GLOBALS['TL_LANGUAGE'] = $strLanguage;
     \System::loadLanguageFile('default', $strLanguage, true);
     Isotope::setConfig($objOrder->getRelated('config_id'));
     if (($objCart = $objOrder->getRelated('source_collection_id')) !== null && $objCart instanceof Cart) {
         Isotope::setCart($objCart);
     }
 }
 /**
  * @param Product|\Model                 $product
  * @param ProductCollection\Order|\Model $order
  *
  * @return array
  */
 private static function createStockChangeNotifictionTokens(Product $product, ProductCollection\Order $order)
 {
     $tokens = [];
     $tokens['admin_email'] = $GLOBALS['TL_ADMIN_EMAIL'];
     /** @var Config|\Model $config */
     $config = $order->getRelated('config_id');
     foreach ($product->row() as $k => $v) {
         $tokens['product_' . $k] = $v;
     }
     foreach ($order->row() as $k => $v) {
         $tokens['order_' . $k] = $v;
     }
     foreach ($config->row() as $k => $v) {
         $tokens['config_' . $k] = $v;
     }
     return $tokens;
 }