function ProductListSorter()
 {
     global $application;
     #check if fatal errors exist in the block tag
     $this->NoView = false;
     if ($application->issetBlockTagFatalErrors("ProductListSorter")) {
         $this->NoView = true;
     }
     $_links_to_display = array_filter(array_map('trim', explode(',', $application->getAppIni('PRODUCT_LIST_SORTER_LINKS'))));
     foreach ($_links_to_display as $item) {
         $this->__sort_field_list_to_display[$item] = cz_getMsg($item);
     }
 }
 function outputViewAllLink()
 {
     $value = '';
     if ($this->was_randomized) {
         $request = new Request();
         $request->setView(CURRENT_REQUEST_URL);
         $request->setKey('bs_no_rand', 1);
         $url = $request->getURL();
         $msg = cz_getMsg('VIEW_ALL_LABEL');
         $value = str_replace('{URL}', $url, $msg);
     }
     return $value;
 }
 function getTag($tag)
 {
     global $application;
     $value = null;
     switch ($tag) {
         case 'Local_AddPromoCode_URL':
             $request = new Request();
             $request->setView(CURRENT_REQUEST_URL);
             $request->setAction('AddPromoCode');
             #$request->setKey( 'promo_code', '' );
             $value = $request->getURL();
             break;
         case 'Local_AddPromoCode_Error':
             $AddPromoCodeError = modApiFunc("PromoCodes", "getAddPromoCodeError");
             modApiFunc("PromoCodes", "setAddPromoCodeError", "");
             if (!empty($AddPromoCodeError)) {
                 $value = getMsg('SYS', $AddPromoCodeError);
             } else {
                 $value = "";
             }
             break;
         case 'Local_RemovePromoCode_URL':
             $request = new Request();
             $request->setView(CURRENT_REQUEST_URL);
             $request->setAction('RemovePromoCode');
             $value = $request->getURL();
             break;
         case 'Local_PromoCode':
             $value = '';
             if ($this->pc_info !== false) {
                 $value = prepareHTMLDisplay($this->pc_info["promo_code"]);
             }
             break;
         case 'Local_PromoCodeDiscountedItemsListForCZ':
             $value = '';
             if ($this->pc_info !== false && $this->applicable === true) {
                 $home_present = false;
                 $cat_names = array();
                 $prod_names = array();
                 if ($this->pc_info['cats'] != null) {
                     $cats = explode('|', $this->pc_info['cats']);
                     foreach ($cats as $cid) {
                         $cat_obj = new CCategoryInfo($cid);
                         if ($cat_obj->_fCategoryIDIsIncorrect === true) {
                             continue;
                         }
                         // Home category present, we do not need anything else
                         if ($cid == 1) {
                             $home_present = true;
                             $cat_names = array();
                             $cat_names[] = cz_getMsg('PROMOCODE_HOME_CATEGORY_NAME_SUBST');
                             break;
                         } else {
                             $cat_names[] = $cat_obj->getCategoryTagValue('Name');
                         }
                     }
                 }
                 if ($this->pc_info['prods'] != null && !$home_present) {
                     $prods = explode('|', $this->pc_info['prods']);
                     foreach ($prods as $pid) {
                         $obj = new CProductInfo($pid);
                         if (!$obj->isProductIdCorrect()) {
                             continue;
                         }
                         $prod_names[] = $obj->getProductTagValue('Name');
                     }
                 }
                 if ($cat_names) {
                     $cat_names_str = implode(', ', $cat_names);
                     if ($home_present) {
                         $value .= $cat_names_str;
                     } else {
                         if (count($cat_names) == 1) {
                             $value .= cz_getMsg("PROMOCODE_CATEGORY_LABEL") . $cat_names_str;
                         } else {
                             $value .= cz_getMsg("PROMOCODE_CATEGORIES_LABEL") . $cat_names_str;
                         }
                     }
                     if ($prod_names) {
                         $value .= cz_getMsg("PROMOCODE_AND_LABEL");
                     }
                 }
                 if ($prod_names) {
                     $prod_names_str = implode(', ', $prod_names);
                     if (count($prod_names) == 1) {
                         $value .= cz_getMsg("PROMOCODE_PRODUCT_LABEL") . $prod_names_str;
                     } else {
                         $value .= cz_getMsg("PROMOCODE_PRODUCTS_LABEL") . $prod_names_str;
                     }
                 }
             }
             break;
         case 'Local_PromoCodeMinSubtotal':
             $value = '';
             if ($this->pc_info !== false && $this->applicable === true && $this->pc_info["min_subtotal"] != 0) {
                 $min_subtotal = modApiFunc("Localization", "currency_format", $this->pc_info["min_subtotal"]);
                 $value = str_replace('{MINSUBTOTAL}', $min_subtotal, cz_getMsg('PROMOCODE_MINSUBTOTAL_NEEDED'));
             }
             break;
         case 'Local_PromoCodeDiscount':
             $value = '';
             if ($this->pc_info !== false && $this->applicable === true) {
                 $o_subtotal = modApiFunc("Checkout", "getOrderPrice", "Subtotal", modApiFunc("Localization", "getMainStoreCurrency"));
                 $value = modApiFunc("Localization", "currency_format", modApiFunc("PromoCodes", "getPromoCodeDiscount", $o_subtotal, modApiFunc("PromoCodes", "getPromoCodeId"), array()));
             }
             if ($value == "") {
                 $value = modApiFunc("Localization", "currency_format", PRICE_N_A);
             }
             break;
         case 'Local_PromoCodeDiscountText':
             //        "10%"     "$2"          ,
             //               .
             $value = "";
             if ($this->pc_info !== false && $this->applicable === true) {
                 switch ($this->pc_info["discount_cost_type_id"]) {
                     case 1:
                         $value = modApiFunc("Localization", "currency_format", $this->pc_info["discount_cost"]);
                         break;
                     case 2:
                         $value = modApiFunc("Localization", "num_format", $this->pc_info["discount_cost"]) . "%";
                         break;
                     default:
                         //: report error.
                         exit(1);
                 }
             }
             break;
         case 'Local_PromoCodeStrictCartAttitude':
             $value = '';
             if ($this->pc_info && $this->pc_info['strict_cart'] == PROMO_CODE_STRICT_CART) {
                 // get product IDs and their categories' IDs
                 $prod = $coupon_cart = array();
                 $promo_codes = $application->getInstance('PromoCodes');
                 $order_cart = modApiFunc("Cart", "getCartContentExt");
                 foreach ($order_cart as $product) {
                     $coupon_cart[] = array('id' => $product["ID"], 'cat' => $product['CategoryID'], 'total' => $product['TotalExcludingTaxes']);
                 }
                 // coupon not applicable due to not meeting coupon conditions
                 if (false == $promo_codes->isPromoCodeAreaApplicable($this->pc_info, $coupon_cart)) {
                     $value = cz_getMsg('PROMOCODE_STRICT_CART_NEEDED');
                 }
             }
             break;
         case 'Local_PromoCodeShippingAttitude':
             $value = '';
             if ($this->pc_info !== false && $this->applicable === true) {
                 if ($this->pc_info['free_shipping'] == PROMO_CODE_FORBIDS_FREE_SHIPPING) {
                     $value = cz_getMsg('PROMOCODE_FREE_SHIPPING_FORBIDDEN');
                 } else {
                     if ($this->pc_info['free_shipping'] == PROMO_CODE_GRANTS_FREE_SHIPPING) {
                         $value = cz_getMsg('PROMOCODE_FREE_SHIPPING_GRANTED');
                     }
                 }
             }
             break;
         case 'Local_PromoCodeHandlingAttitude':
             $value = '';
             if ($this->pc_info !== false && $this->applicable === true) {
                 if ($this->pc_info['free_handling'] == PROMO_CODE_FORBIDS_FREE_HANDLING) {
                     $value = cz_getMsg('PROMOCODE_FREE_HANDLING_FORBIDDEN');
                 } else {
                     if ($this->pc_info['free_handling'] == PROMO_CODE_GRANTS_FREE_HANDLING) {
                         $value = cz_getMsg('PROMOCODE_FREE_HANDLING_GRANTED');
                     }
                 }
             }
             break;
         case 'Local_PromoCodeGlobalDiscountIgnored':
             $value = '';
             if ($this->pc_info !== false && $this->applicable === true) {
                 if ($this->pc_info['b_ignore_other_discounts'] == 1) {
                     // ignore global discount
                     $value = cz_getMsg('PROMOCODE_GLOBAL_DISCOUNT_IGNORED');
                 }
             }
             break;
         default:
             $value = NULL;
             break;
     }
     return $value;
 }
 function outputTax()
 {
     global $application;
     $retval = "";
     $this->_Tax_Item = array();
     $tax = modApiFunc("Taxes", "getTax");
     //                                             -
     switch (modApiFunc("TaxExempts", "getFullTaxExemptStatus")) {
         case DB_TRUE:
             $tax['TaxSubtotalAmountView'][] = array('view' => cz_getMsg("FULL_TAX_EXEMPT_MSG"), 'value' => -1 * modApiFunc("Checkout", "getOrderPrice", "Tax_NoExempts", modApiFunc("Localization", "getMainStoreCurrency")));
             break;
         default:
             break;
     }
     $lastPlacedOrderID = modApiFunc('Checkout', 'getLastPlacedOrderID');
     if ($lastPlacedOrderID !== NULL) {
         $oi = modApiFunc('Checkout', 'getOrderInfo', $lastPlacedOrderID, modApiFunc('Localization', 'whichCurrencyToDisplayOrderIn', $lastPlacedOrderID));
         $tax['TaxSubtotalAmountView'] = array();
         foreach ($oi['Price']['tax_dops'] as $tax_info) {
             $tax['TaxSubtotalAmountView'][] = array('view' => preg_replace("/:\$/", '', $tax_info["name"]), 'value' => $tax_info['value']);
         }
     }
     foreach ($tax['TaxSubtotalAmountView'] as $taxView) {
         $dont_convert = modApiFunc('Checkout', 'getCurrentStepID') == 4 ? true : false;
         $this->_Tax_Item['Local_TaxName'] = prepareHTMLDisplay($taxView['view']);
         $this->_Tax_Item['Local_TaxAmount'] = modApiFunc("Localization", "currency_format", $taxView['value'], $dont_convert);
         $application->registerAttributes($this->_Tax_Item);
         $retval .= $this->templateFiller->fill("ItemTax");
     }
     return $retval;
 }
 function getTag($tag)
 {
     $value = null;
     switch ($tag) {
         case 'Local_MessagesList':
             $value = $this->out_MessagesList();
             break;
         case 'Local_Message':
             $value = cz_getMsg($this->current_message);
             break;
         case 'Local_ErrorNumber':
             $value = $this->current_error_number;
             break;
         case 'Local_ErrorMessage':
             if (preg_match("/^E_.+/", $this->current_error_message)) {
                 $value = cz_getMsg($this->current_error_message);
             } else {
                 $value = $this->current_error_message;
             }
             break;
     }
     return $value;
 }
function Local_InvoicePDF_info($order_id, $val)
{
    if (strcmp($val, "invoicepdf") == 0) {
        $r = new Request();
        $r->setView(CURRENT_REQUEST_URL);
        $r->setAction('get_invoice_pdf');
        $r->setKey('order_id', $order_id);
        modApiFunc('Session', 'set', 'plugin_return_action', '<a target="_blank" href="' . $r->getURL() . '">' . cz_getMsg('ACCOUNT_INVOICE_ORDER_PDF') . '</a>');
    } else {
        modApiFunc('Session', 'set', 'plugin_return_action', '');
    }
}
 function onAction()
 {
     global $application;
     $settings = modApiFunc('Customer_Account', 'getSettings');
     $request =& $application->getInstance('Request');
     $customer_info = $request->getValueByKey('customer_info');
     $passwd = array('passwd' => $customer_info['Customer']['Password'], 're-type' => $customer_info['Customer']['RePassword']);
     unset($customer_info['Customer']['Password'], $customer_info['Customer']['RePassword']);
     $validator =& $application->getInstance('CAValidator');
     $invalid_fields = array();
     $errors = array();
     if (!$validator->isValid('passwd', $passwd)) {
         $errors[] = 'E_INVALID_PASSWD';
         $invalid_fields[] = 'Password';
         $invalid_fields[] = 'RePassword';
     }
     $required = array();
     $visible_names = array();
     $rg_info = modApiFunc('Customer_Account', 'getPersonInfoGroupInfoByName', 'Customer');
     $rg_attrs = modApiFunc('Customer_Account', 'getPersonInfoGroupAttrs', $rg_info['group_id']);
     foreach ($rg_attrs as $a_info) {
         if ($a_info['is_required'] == 'Y') {
             $required[] = $a_info['attr_name'];
         }
         $visible_names[$a_info['attr_name']] = $a_info['visible_name'];
     }
     $country = null;
     $state = null;
     $state_text = null;
     foreach ($customer_info['Customer'] as $attr_name => $attr_value) {
         if (!in_array($attr_name, $required) and $attr_value == '') {
             continue;
         }
         $customer_info['Customer'][$attr_name] = $attr_value = trim($attr_value);
         switch ($attr_name) {
             case 'Country':
                 $country = $attr_value;
                 break;
             case 'State':
                 $state = $attr_value;
                 break;
             case 'State_text':
                 $state_text = $attr_value;
                 break;
             default:
                 if (!$validator->isValid($attr_name, $attr_value) or in_array($attr_name, $required) and $attr_value == '') {
                     $errors[] = cz_getMsg('E_INVALID_FIELD', $visible_names[$attr_name]);
                     $invalid_fields[] = $attr_name;
                 }
                 break;
         }
         $customer_info['Customer'][$attr_name] = $attr_value;
     }
     if ($country != null) {
         if ($validator->isValid('Country', $country)) {
             if ($state != null or $state_text != null) {
                 $tmp_arr = array('country_id' => $country, 'state_id' => $state, 'state_text' => $state_text);
                 if (!$validator->isValid('country_state', $tmp_arr)) {
                     $errors[] = cz_getMsg('E_INVALID_FIELD', $visible_names['State']);
                     $invalid_fields[] = 'State';
                 }
             }
         } else {
             $errors[] = cz_getMsg('E_INVALID_FIELD', $visible_names['Country']);
             $invalid_fields[] = 'Country';
         }
     }
     if (empty($errors)) {
         $account_name = $settings['AUTH_SCHEME'] == AUTH_SCHEME_BY_LOGIN ? $customer_info['Customer']['AccountName'] : $customer_info['Customer']['Email'];
         if (modApiFunc('Customer_Account', 'doesAccountExists', $account_name)) {
             $errors[] = 'E_ACCOUNT_EXISTS';
             $invalid_fields[] = $settings['AUTH_SCHEME'] == AUTH_SCHEME_BY_LOGIN ? 'AccountName' : 'Email';
         } else {
             if (!modApiFunc('Customer_Account', 'registerAccount', $account_name, $passwd['passwd'], $customer_info['Customer'])) {
                 $errors[] = 'E_NOT_REGISTERED';
             }
         }
     }
     $target_view = 'Registration';
     $target_url = '';
     if (!empty($errors)) {
         modApiFunc('Session', 'set', 'RegisterErrors', $errors);
         modApiFunc('Session', 'set', 'customer_info', $customer_info);
         modApiFunc('Session', 'set', 'invalid_fields', $invalid_fields);
     } else {
         $obj =& $application->getInstance('CCustomerInfo', $account_name);
         $reg_data = array('account' => $account_name, 'info' => $customer_info['Customer']);
         modApiFunc('EventsManager', 'throwEvent', 'CustomerRegistered', $reg_data);
         switch ($settings['ACCOUNT_ACTIVATION_SCHEME']) {
             case ACCOUNT_ACTIVATION_SCHEME_NONE:
                 modApiFunc('Customer_Account', 'dropActivationKey', $account_name, 'customer_account');
                 $obj->SignIn();
                 if (modApiFunc('Session', 'is_set', 'toCheckoutAfterSignIn')) {
                     modApiFunc('Session', 'un_set', 'toCheckoutAfterSignIn');
                     $target_view = 'CheckoutView';
                 } elseif (modApiFunc('Session', 'is_set', 'toURLAfterSignIn')) {
                     $target_url = modApiFunc('Session', 'get', 'toURLAfterSignIn');
                     modApiFunc('Session', 'un_set', 'toURLAfterSignIn');
                 } else {
                     modApiFunc('Session', 'set', 'ResultMessage', 'MSG_REGISTERED');
                     $target_view = 'CustomerAccountHome';
                 }
                 break;
             case ACCOUNT_ACTIVATION_SCHEME_BY_ADMIN:
                 modApiFunc('EventsManager', 'throwEvent', 'AdminShouldActivateCustomer', $account_name);
                 modApiFunc('Session', 'set', 'ResultMessage', 'MSG_REGISTERED_NEED_ACTIVATE_BY_ADMIN');
                 $target_view = 'AccountActivation';
                 break;
             case ACCOUNT_ACTIVATION_SCHEME_BY_CUSTOMER:
                 modApiFunc('EventsManager', 'throwEvent', 'CustomerShouldActivateSelf', $account_name);
                 modApiFunc('Session', 'set', 'ResultMessage', 'MSG_REGISTERED_NEED_ACTIVATE_BY_CUSTOMER');
                 $target_view = 'AccountActivation';
                 break;
         }
     }
     if ($target_url != '') {
         $r = new Request($target_url);
     } else {
         $r = new Request();
         $r->setView($target_view);
     }
     $application->redirect($r);
 }
 function onAction()
 {
     global $application;
     $ca_msg_obj =& $application->getInstance('MessageResources', 'customer-account-messages', 'AdminZone');
     $invalid_fields = array();
     $email = modApiFunc('Customer_Account', 'getCurrentSignedCustomer');
     $new_email = $email;
     if ($email == null) {
         $r = new Request();
         $r->setView('Index');
         $application->redirect($r);
     } else {
         $result_messages_array = array();
         $errors_array = array();
         $request = new Request();
         $customer_info = $request->getValueByKey('customer_info');
         $customer_obj =& $application->getInstance('CCustomerInfo', $email);
         $validator =& $application->getInstance('CAValidator');
         foreach ($customer_info as $group_name => $group_attrs) {
             $country = null;
             $state = null;
             $state_text = null;
             $passwd = array('passwd' => null, 're-type' => null);
             $required = array();
             if ($group_name == 'Customer') {
                 $rg_info = modApiFunc('Customer_Account', 'getPersonInfoGroupInfoByName', 'Customer');
                 $rg_attrs = modApiFunc('Customer_Account', 'getPersonInfoGroupAttrs', $rg_info['group_id']);
                 foreach ($rg_attrs as $a_info) {
                     if ($a_info['is_required'] == 'Y') {
                         $required[] = $a_info['attr_name'];
                     }
                 }
             }
             foreach ($group_attrs as $attr_name => $attr_value) {
                 if (!preg_match('/password/i', $attr_name) and $attr_value == '' and in_array($attr_name, $required)) {
                     $attr_info = $customer_obj->getPersonInfoAttrInfoByName($attr_name, $group_name);
                     $group_info = $customer_obj->getPersonInfoGroupInfoByName($group_name);
                     $errors_array[] = cz_getMsg('ERROR_MESSAGE_INVALID_FIELD_VALUE', $attr_info['visible_name'], $ca_msg_obj->getMessage($group_info['lang_code']));
                     $invalid_fields[$group_name][] = $attr_name;
                     continue;
                 }
                 switch ($attr_name) {
                     case 'Country':
                         $country = $attr_value;
                         break;
                     case 'State':
                         $state = $attr_value;
                         break;
                     case 'State_text':
                         $state_text = $attr_value;
                         break;
                     case 'Password':
                         $passwd['passwd'] = $attr_value;
                         break;
                     case 'RePassword':
                         $passwd['re-type'] = $attr_value;
                         break;
                     default:
                         if ($validator->isValid($attr_name, $attr_value)) {
                             //                email          Customer,                  account name
                             if ($group_name == 'Customer' && $attr_name == 'Email' && $attr_value !== $email) {
                                 $new_customer_email = $attr_value;
                                 //                 $new_customer_email                           ,
                                 //             ,                                   .             ,
                                 //          $new_customer_email          .
                                 //               ,                          :
                                 if (modApiFunc('Customer_Account', 'doesAccountExists', $new_customer_email) == true) {
                                     //
                                     $errors_array[] = cz_getMsg('ERROR_MESSAGE_EMAIL_ALREADY_USED', $new_customer_email);
                                     $invalid_fields[$group_name][] = $attr_name;
                                 } else {
                                     //            account name,            email          Customer
                                     $customer_obj->changeAccountName($new_customer_email);
                                     $customer_obj->setPersonInfo(array(array($attr_name, $attr_value, $group_name)));
                                 }
                             } else {
                                 $customer_obj->setPersonInfo(array(array($attr_name, $attr_value, $group_name)));
                             }
                         } else {
                             if ($attr_value != '') {
                                 $attr_info = $customer_obj->getPersonInfoAttrInfoByName($attr_name, $group_name);
                                 $group_info = $customer_obj->getPersonInfoGroupInfoByName($group_name);
                                 $errors_array[] = cz_getMsg('ERROR_MESSAGE_INVALID_FIELD_VALUE', $attr_info['visible_name'], $ca_msg_obj->getMessage($group_info['lang_code']));
                                 $invalid_fields[$group_name][] = $attr_name;
                             }
                         }
                         break;
                 }
             }
             if ($country != null) {
                 if ($validator->isValid('Country', $country)) {
                     $customer_obj->setPersonInfo(array(array('Country', $country, $group_name)));
                     if ($state != null or $state_text != null) {
                         $tmp_arr = array('country_id' => $country, 'state_id' => $state, 'state_text' => $state_text);
                         if ($validator->isValid('country_state', $tmp_arr)) {
                             $customer_obj->setPersonInfo(array(array('State', $tmp_arr['state_id'], $group_name)));
                         }
                     }
                 }
             }
             $_tmp = array_filter($passwd);
             if (!empty($_tmp)) {
                 if ($validator->isValid('passwd', $passwd)) {
                     if ($customer_obj->changePassword($passwd['passwd'])) {
                         $result_messages_array[] = 'MSG_PASSWD_UPDATED';
                     } else {
                         $errors_array[] = 'E_PASSWD_NOT_UPDATED';
                     }
                 } else {
                     $errors_array[] = 'E_INVALID_PASSWD';
                 }
             }
         }
         $customer_obj->refreshCheckoutPrerequisites();
         if (empty($errors_array)) {
             $result_messages_array[] = 'MSG_PERSONAL_INFO_SAVED';
         }
         if (!empty($result_messages_array)) {
             modApiFunc('Session', 'set', 'ResultMessage', $result_messages_array);
         }
         if (!empty($errors_array)) {
             modApiFunc('Session', 'set', 'RegisterErrors', $errors_array);
         }
         modApiFunc('Session', 'set', 'InvalidFields', $invalid_fields);
         $r = new Request();
         $r->setView('CustomerPersonalInfo');
         $application->redirect($r);
     }
 }
 /**
  * Gets the unit symbol.
  *
  * @param string $entity - the entity, the units: 'currency', 'weight', 'item'
  * @return the unit symbol
  */
 function getUnitTypeValue($entity)
 {
     $value = '';
     switch ($entity) {
         case 'currency':
             $value = $this->getCurrencySign();
             break;
         case 'weight':
             $value = prepareHTMLDisplay($this->getValue('WEIGHT_UNIT'));
             break;
         case 'item':
             $value = prepareHTMLDisplay(cz_getMsg('ITEM_UNIT'));
             break;
     }
     return $value;
 }
 /**
  * Updates the cart contents.
  */
 function onAction()
 {
     global $application;
     $request = $application->getInstance('Request');
     $msgres = $application->getInstance("MessageResources", "messages");
     $cart_id = $request->getValueByKey('cart_id');
     $quantity_in_cart = $request->getValueByKey('quantity_in_cart');
     if (!is_array($cart_id)) {
         $cart_id = array(0 => $cart_id);
     }
     if (!is_array($quantity_in_cart)) {
         $quantity_in_cart = array(0 => $quantity_in_cart);
     }
     if (is_array($cart_id)) {
         for ($i = 0; $i < sizeof($cart_id); $i++) {
             $obj_cart =& $application->getInstance('Cart');
             if (!isset($obj_cart->CartContent[$cart_id[$i]])) {
                 continue;
             }
             $quantity_in_cart[$i] *= 1;
             if (is_int($quantity_in_cart[$i]) && $quantity_in_cart[$i] > 0 && is_string($cart_id[$i]) && _ml_strlen($cart_id[$i]) > 2) {
                 list($prod_id) = explode('_', $cart_id[$i]);
                 $obj_product = new CProductInfo($prod_id);
                 if ($obj_product->isProductIdCorrect() == false) {
                     continue;
                 }
                 $stock_method = $obj_product->whichStockControlMethod();
                 $qty_in_stock = $obj_product->getProductTagValue('QuantityInStock', PRODUCTINFO_NOT_LOCALIZED_DATA);
                 $sum_qty = $quantity_in_cart[$i];
                 //                          -        Stock.
                 if ($stock_method == PRODUCT_QUANTITY_IN_STOCK_ATTRIBUTE) {
                     //          ,                                    ,
                     if ($qty_in_stock != '' && $qty_in_stock < $sum_qty && modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_ALLOW_BUY_MORE_THAN_STOCK) === false) {
                         modApiFunc("Session", 'set', 'ShoppingCartResultMessage', cz_getMsg("ERR_NOT_ALLOWED_TO_BUY_MORE_THAN_IN_STOCK"));
                     } else {
                         //         ,               "min order"               -                                       .
                         $min_order = $obj_product->getProductTagValue('MinQuantity', PRODUCTINFO_NOT_LOCALIZED_DATA);
                         if ($min_order != '' && $min_order > $sum_qty) {
                             modApiFunc("Session", 'set', 'ShoppingCartResultMessage', $msgres->getMessage("ERR_NOT_ALLOWED_TO_BUY_LESS_THAN_MIN_ORDER", array($obj_product->getProductTagValue('MinQuantity'))));
                         } else {
                             modApiFunc('Cart', 'updateQuantityInCart', $cart_id[$i], $quantity_in_cart[$i]);
                         }
                     }
                 } else {
                     //          ,                                    ,
                     $obj_cart =& $application->getInstance('Cart');
                     $options = $obj_cart->CartContent[$cart_id[$i]]['options'];
                     $inv_id = modApiFunc("Product_Options", "getInventoryIDByCombination", 'product', $prod_id, $options);
                     if ($inv_id != null) {
                         $options_settings = modApiFunc("Product_Options", "getOptionsSettingsForEntity", 'product', $prod_id);
                         $inv_info = modApiFunc('Product_Options', 'getInventoryInfo', $inv_id);
                         if ($options_settings['AANIS'] == 'N' && $inv_info['quantity'] < $sum_qty && modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_ALLOW_BUY_MORE_THAN_STOCK) === false) {
                             modApiFunc("Session", 'set', 'ShoppingCartResultMessage', cz_getMsg("ERR_NOT_ALLOWED_TO_BUY_MORE_THAN_IN_STOCK", $obj_product->getProductTagValue('MinQuantity')));
                         } else {
                             modApiFunc('Cart', 'updateQuantityInCart', $cart_id[$i], $quantity_in_cart[$i]);
                         }
                     } else {
                         $options_settings = modApiFunc("Product_Options", "getOptionsSettingsForEntity", 'product', $prod_id);
                         if ($options_settings['AANIC'] == 'Y') {
                             modApiFunc('Cart', 'updateQuantityInCart', $cart_id[$i], $quantity_in_cart[$i]);
                         }
                     }
                 }
             }
         }
     }
     $request = new Request();
     $request->setView(CURRENT_REQUEST_URL);
     $application->redirect($request);
 }
 function getTag($tag)
 {
     $value = null;
     if (preg_match("/^local_(.+)\$/i", $tag, $matches)) {
         switch (strtolower($matches[1])) {
             case 'invoice':
                 $r = new Request();
                 $r->setView('CustomerOrderInvoice');
                 $r->setKey('order_id', $this->order_id);
                 $value = '<a target="_blank" href="' . $r->getURL() . '">' . cz_getMsg('ORDER_INFO_KEY_FIELD_INVOICE_LINK') . '</a>';
                 break;
             case "orderdate":
                 $value = $this->__format_date($this->order_info['Date']);
                 if (empty($value)) {
                     $value = '--';
                 }
                 break;
             case "orderstatus":
                 $value = $this->order_info['Status'];
                 if (empty($value)) {
                     $value = '--';
                 }
                 break;
             case "orderpaymentstatus":
                 $value = $this->order_info['PaymentStatus'];
                 if (empty($value)) {
                     $value = '--';
                 }
                 break;
             case "orderpaymentmethod":
                 $value = $this->order_info['PaymentMethod'];
                 if (empty($value)) {
                     $value = '--';
                 }
                 break;
             case "orderpaymentprocessororderid":
                 $value = $this->order_info['PaymentProcessorOrderId'];
                 if (empty($value)) {
                     $value = '--';
                 }
                 break;
             case "ordershippingmethod":
                 $value = $this->order_info['ShippingMethod'];
                 if (empty($value)) {
                     $value = '--';
                 }
                 break;
             case "ordertrackid":
                 $value = nl2br($this->order_info['TrackId']);
                 if (empty($value)) {
                     $value = '--';
                 }
                 break;
             case 'orderid':
                 $value = $this->order_info['ID'];
                 break;
             case 'items':
                 $value = $this->out_Items();
                 break;
             case 'groupname':
                 $value = cz_getMsg('ORDER_INFO_GROUP_' . $this->current_info_group['lang_suffix']);
                 break;
             case 'fieldname':
                 $value = $this->current_info_field['display_name'];
                 break;
             case 'fieldvalue':
                 $value = $this->current_info_field['value'];
                 break;
             case 'orderedproducts':
                 $value = $this->out_ProductsList();
                 break;
             case 'productlist':
                 $value = $this->templateFiller->fill('ProductsContainer');
                 break;
             case 'orderprices':
                 $value = $this->out_Prices();
                 break;
             case 'pricename':
                 $value = $this->current_price_info['display_name'];
                 break;
             case 'pricevalue':
                 $value = $this->current_price_info['value'];
                 break;
             case 'productid':
                 $value = $this->current_product_info['storeProductID'];
                 break;
             case 'productsku':
                 $value = array_key_exists('SKU', $this->current_product_info) ? $this->current_product_info['SKU'] : null;
                 break;
             case 'productname':
                 $value = $this->current_product_info['name'];
                 break;
             case 'productquantity':
                 $value = $this->current_product_info['qty'];
                 break;
             case 'productsaleprice':
                 $value = modApiFunc('Localization', 'currency_format', $this->current_product_info['SalePrice']);
                 break;
             case 'productlistprice':
                 $value = modApiFunc('Localization', 'currency_format', $this->current_product_info['ListPrice']);
                 break;
             case 'productmanufacturer':
                 $value = $this->current_product_info['Manufacturer'];
                 break;
             case 'productsmallimage':
                 $value = $this->current_product_info['SmallImage'];
                 break;
             case 'productlargeimage':
                 $value = $this->current_product_info['LargeImage'];
                 break;
             case 'productshortdescription':
                 $value = $this->current_product_info['ShortDescription'];
                 break;
             case 'productdetaileddescription':
                 $value = $this->current_product_info['DetailedDescription'];
                 break;
             case 'productamount':
                 $value = modApiFunc('Localization', 'currency_format', $this->current_product_info['SalePrice'] * $this->current_product_info['qty']);
                 break;
             case 'productoptions':
                 if (isset($this->current_product_info['options']) and !empty($this->current_product_info['options'])) {
                     $value = $this->templateFiller->fill('ProductOptionsContainer');
                 }
                 break;
             case 'optionslist':
                 $value = $this->out_OptionsList();
                 break;
             case 'optionname':
                 $value = $this->current_option_info['option_name'];
                 break;
             case 'optionvalue':
                 $value = $this->current_option_info['option_value'];
                 break;
             case 'productfileslink':
                 $orderInfo = modApiFunc("Checkout", "getBaseOrderInfo", $this->order_id);
                 if ($orderInfo["PaymentStatus"] == "Fully Paid" && count(modApiFunc('Product_Files', 'getHotlinksList', $this->current_product_info['id'])) > 0) {
                     $r = new Request();
                     $r->setView('CustomerOrderDownloadLinks');
                     $r->setKey('order_id', $this->order_id);
                     $r->setKey('order_product_id', $this->current_product_info['id']);
                     $value = '<a href="' . $r->getURL() . '">' . cz_getMsg('ORDERED_PRODUCT_FILES_LINK') . '</a>';
                 }
                 break;
             case 'forcedorderid':
                 $value = $this->forced_order_id;
                 break;
             default:
                 if (preg_match('/^product(.+)custom$/i', $matches[1], $m)) {
                     foreach ($this->current_product_info['custom_attributes'] as $cattr_info) {
                         if (strtolower($m[1]) == strtolower($cattr_info['tag'])) {
                             $value = $cattr_info['value'];
                         }
                     }
                 } else {
                     if (isset($this->direct_tags[$tag])) {
                         $value = $this->direct_tags[$tag];
                     } else {
                         $value = '';
                     }
                 }
                 break;
         }
     } else {
         if (preg_match('/^product(.+)custom$/i', $tag, $matches)) {
             foreach ($this->current_product_info['custom_attributes'] as $cattr_info) {
                 if (_ml_strtolower($matches[1]) == _ml_strtolower($cattr_info['tag'])) {
                     $value = $cattr_info['value'];
                 }
             }
         }
     }
     if ($value == '') {
         do_action("customer_order_info", $this->order_id, strtolower($matches[1]));
         $value = modApiFunc('Session', 'get', 'plugin_return_action');
     }
     return $value;
 }
 function out_FilterInfo()
 {
     $lang_suffix = 'custom';
     switch ($this->incoming_filter['type']) {
         case 'quick':
             switch ($this->incoming_filter['order_status']) {
                 case ORDER_STATUS_ALL:
                     $lang_suffix = 'all';
                     break;
                 case ORDER_STATUS_NEW:
                     $lang_suffix = 'new';
                     break;
                 case ORDER_STATUS_IN_PROGRESS:
                     $lang_suffix = 'in_progress';
                     break;
                 case ORDER_STATUS_READY_TO_SHIP:
                     $lang_suffix = 'ready_to_ship';
                     break;
                 case ORDER_STATUS_SHIPPED:
                     $lang_suffix = 'shipped';
                     break;
                 case ORDER_STATUS_CANCELLED:
                     $lang_suffix = 'cancelled';
                     break;
                 case ORDER_STATUS_DECLINED:
                     $lang_suffix = 'declined';
                     break;
                 case ORDER_STATUS_COMPLETED:
                     $lang_suffix = 'completed';
                     break;
             }
             break;
         case 'id':
             $lang_suffix = 'by_id';
             break;
     }
     $filter_name = cz_getMsg('ORDER_STATUS_' . _ml_strtoupper($lang_suffix));
     if ($this->customer_obj->getOrdersCount() == 0) {
         $lang_suffix = 'none';
     } else {
         $lang_suffix = 'summary';
     }
     $currency_id = modApiFunc("Localization", "getMainStoreCurrency");
     modApiFunc("Localization", "pushDisplayCurrency", $currency_id, $currency_id);
     $ret = cz_getMsg('ORDER_FILTER_INFO_' . _ml_strtoupper($lang_suffix), $filter_name, $this->customer_obj->getOrdersCount(), $this->__format_date($this->customer_obj->getOrdersMinDate()), $this->__format_date($this->customer_obj->getOrdersMaxDate()), modApiFunc('Localization', 'currency_format', $this->customer_obj->getOrdersAmount()));
     modApiFunc("Localization", "popDisplayCurrency");
     return $ret;
 }