/** * Returns the product info. * * @return string. */ function output() { global $application; #Define whether to output the view or not if ($this->NoView) { $application->outputTagErrors(true, "CustomerReviewsProductInfo", "Errors"); return ""; } else { $application->outputTagErrors(true, "CustomerReviewsProductInfo", "Warnings"); } $catalog =& $application->getInstance('Catalog'); $this->prod_id = @func_get_arg(0); if ($this->prod_id === false) { $this->prod_id = $catalog->getCurrentProductID(); } if (!$this->prod_id) { return; } modApiFunc("tag_param_stack", "push", __CLASS__, array(array("key" => TAG_PARAM_PROD_ID, "value" => $this->prod_id))); # Get current selected product info. $product_info = modApiFunc('Catalog', 'getProductInfo', $this->prod_id); # save info $this->_ProductInfo = $product_info; # Related $this->_rp_output = getRelatedProducts($this->prod_id); # $application->registerAttributes(array('Local_HiddenFields' => '', 'Local_JSfuncProductFormSubmit' => '', 'Local_ProductStockWarnings' => '', 'ProductOptionsForm' => '', 'Local_ProductFormStart' => '', 'Local_ProductFormEnd' => '', 'Local_ProductAddToCart' => '', 'Local_FormQuantityFieldName' => '', 'Local_ProductQuantityOptions' => '', 'RelatedProducts' => '')); $templateFiller = new TemplateFiller(); # define the template for the given view. $template = $application->getBlockTemplate('CustomerReviewsProductInfo'); $templateFiller->setTemplate($template); $obj_product = new CProductInfo($this->prod_id); $stock_method = $obj_product->whichStockControlMethod(); if ($stock_method == PRODUCT_OPTIONS_INVENTORY_TRACKING) { // stock , product info // $template = "Item"; } else { // OutOfStock - . // OutOfStock - . $store_show_absent = modApiFunc("Configuration", "getValue", "store_show_absent"); $qty_in_stock = $this->_ProductInfo['attributes']['QuantityInStock']['value']; $low_stock_level = $this->_ProductInfo['attributes']['LowStockLevel']['value']; $b_out_of_stock = $qty_in_stock !== "" && $qty_in_stock < 1; switch ($store_show_absent) { case STORE_SHOW_ABSENT_SHOW_BUY: // < , > - // $template = "Item"; break; case STORE_SHOW_ABSENT_SHOW_NOT_BUY: // < , > // LowStock - <Low Stock! Buy Now!> if ($b_out_of_stock === true) { $template = "ItemOutOfStock"; } else { $template = "Item"; } break; case STORE_SHOW_ABSENT_NOT_SHOW_NOT_BUY: // < , > if ($b_out_of_stock === true) { return ""; } else { $template = "Item"; } break; default: //STORE_SHOW_ABSENT_SHOW_BUY $template = "Item"; break; } } $result = $templateFiller->fill($template, $product_info['TypeID']); modApiFunc("tag_param_stack", "pop", __CLASS__); modApiFunc('EventsManager', 'throwEvent', 'ProductInfoDisplayed', $this->prod_id); return $result; }
/** * Returns the product info. * * @return string. */ function output() { global $application; #Define whether to output the view or not if ($this->NoView) { $application->outputTagErrors(true, "ProductInfo", "Errors"); return ""; } else { $application->outputTagErrors(true, "ProductInfo", "Warnings"); } $catalog =& $application->getInstance('Catalog'); $this->prod_id = @func_get_arg(0); if ($this->prod_id === false) { $this->prod_id = $catalog->getCurrentProductID(); } if (!$this->prod_id || $catalog->getBaseProductInfo($this->prod_id) == null) { $request = new Request(); $request->setView('Index'); $application->redirect($request); return; } else { $product_object = new CProductInfo($this->prod_id); $ms_vis = $product_object->getProductTagValue('MembershipVisibility'); $cur_group_id = modApiFunc('Customer_Account', 'getCurrentSignedCustomerGroupID'); if ($product_object->getProductTagValue('Available') == 'Offline' || $ms_vis != '-1' && !in_array($cur_group_id, explode('|', $ms_vis))) { $request = new Request(); $request->setView('Index'); $application->redirect($request); return; } } /* Determining the IDs of the previous and next product, relively to the current one */ $this->next_product_id = 0; $this->previous_product_id = 0; $product_ids = $catalog->getProductListByGlobalFilter(PAGINATOR_DISABLE); // in the order set in storefront $products_count = count($product_ids); for ($p = 0; $p < $products_count; $p++) { if ($product_ids[$p]['product_id'] == $this->prod_id) { if ($p - 1 >= 0) { $this->previous_product_id = $product_ids[$p - 1]['product_id']; } if ($p + 1 < $products_count) { $this->next_product_id = $product_ids[$p + 1]['product_id']; } break; } } modApiFunc("tag_param_stack", "push", __CLASS__, array(array("key" => TAG_PARAM_PROD_ID, "value" => $this->prod_id))); # Get current selected product info. $product_info = modApiFunc('Catalog', 'getProductInfo', $this->prod_id); # save info $this->_ProductInfo = $product_info; # $_template_tags = array('Local_HiddenFields' => '', 'Local_ProductID' => '', 'Local_JSfuncProductFormSubmit' => '', 'Local_ProductStockWarnings' => '', 'ProductOptionsForm' => '', 'Local_ProductFormStart' => '', 'Local_ProductFormEnd' => '', 'Local_ProductAddToCart' => '', 'Local_FormQuantityFieldName' => '', 'Local_ProductQuantityOptions' => '', 'RelatedProducts' => '', 'NextProductID' => '', 'PreviousProductID' => '', 'Local_ProductSettingsJSON' => '', 'Local_ThumbnailSide' => '', 'ProductColorSwatchImages' => ''); $application->registerAttributes($_template_tags, 'ProductInfo'); $templateFiller = new TemplateFiller(); # define the template for the given view. $template = $application->getBlockTemplate('ProductInfo'); $templateFiller->setTemplate($template); $this->_product_form_action = getpageurl('CartContent'); $obj_product = new CProductInfo($this->prod_id); $stock_method = $obj_product->whichStockControlMethod(); // OutOfStock - . // OutOfStock - . $store_show_absent = modApiFunc("Configuration", "getValue", "store_show_absent"); if ($stock_method == PRODUCT_OPTIONS_INVENTORY_TRACKING) { $qty_in_stock = modApiFunc('Product_Options', 'getQuantityInStockByInventoryTable', 'product', $this->prod_id, true); } else { $qty_in_stock = $this->_ProductInfo['attributes']['QuantityInStock']['value']; } $low_stock_level = $this->_ProductInfo['attributes']['LowStockLevel']['value']; $b_out_of_stock = $qty_in_stock !== "" && $qty_in_stock < 1; switch ($store_show_absent) { case STORE_SHOW_ABSENT_SHOW_BUY: // , - // $template = "Item"; break; case STORE_SHOW_ABSENT_SHOW_NOT_BUY: // , // LowStock - Low Stock! Buy Now! if ($b_out_of_stock === true) { $template = "ItemOutOfStock"; } else { $template = "Item"; } break; case STORE_SHOW_ABSENT_NOT_SHOW_NOT_BUY: // , if ($b_out_of_stock === true) { $request = new Request(); $request->setView('Index'); $application->redirect($request); return ""; } else { $template = "Item"; } break; default: //STORE_SHOW_ABSENT_SHOW_BUY $template = "Item"; break; } $result = $templateFiller->fill($template, $product_info['TypeID']); modApiFunc("tag_param_stack", "pop", __CLASS__); modApiFunc('EventsManager', 'throwEvent', 'ProductInfoDisplayed', $this->prod_id); return $result; }
function processPostedProductData($data, $options_sent, $use_current_cart = true) { global $application; $prod_id = $data['entity_id']; $msgres = $application->getInstance("MessageResources", "messages"); // // , multiple select // : array_flip $for_for = array_keys($data['options']); for ($i = 0; $i < count($for_for); $i++) { if (is_array($data['options'][$for_for[$i]]) and !empty($data['options'][$for_for[$i]]) and isset($data['options'][$for_for[$i]][0]) and is_numeric($data['options'][$for_for[$i]][0])) { $new_arr = array(); for ($j = 0; $j < count($data['options'][$for_for[$i]]); $j++) { $new_arr[$data['options'][$for_for[$i]][$j]] = 'on'; } $data['options'][$for_for[$i]] = $new_arr; } } $is_error = false; $discard_by = 'none'; $stock_discarded_by = 'none'; $stock_discarded_by_warning = ''; $options_settings = modApiFunc("Product_Options", "getOptionsSettingsForEntity", 'product', $prod_id); $product_has_options = count(modApiFunc("Product_Options", "getOptionsList", 'product', $prod_id, USED_FOR_INV)) > 0; $add_to_cart_add_not_replace = modApiFunc('Configuration', 'getValue', SYSCONFIG_STORE_ADD_TO_CART_ADD_NOT_REPLACE); $obj_product = new CProductInfo($prod_id); $stock_method = $obj_product->whichStockControlMethod(); if ($stock_method == PRODUCT_QUANTITY_IN_STOCK_ATTRIBUTE) { // Quantity In Stock Attribute. $qty_in_stock = $obj_product->getProductTagValue('QuantityInStock', PRODUCTINFO_NOT_LOCALIZED_DATA); $qty_already_in_cart = modApiFunc('Cart', 'getProductQuantity', $prod_id); // $sum_qty , if ($add_to_cart_add_not_replace === true && $use_current_cart) { $sum_qty = $qty_already_in_cart + $data['qty']; } else { $sum_qty = $data['qty']; } if ($qty_in_stock != '' && $qty_in_stock < $sum_qty && $use_current_cart && modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_ALLOW_BUY_MORE_THAN_STOCK) === false) { $is_error = true; $stock_discarded_by = $msgres->getMessage("ERR_NOT_ALLOWED_TO_BUY_MORE_THAN_IN_STOCK"); } elseif ($qty_in_stock != '' && $qty_in_stock < $sum_qty && $use_current_cart && modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_ALLOW_BUY_MORE_THAN_STOCK) === true) { $stock_discarded_by_warning = $msgres->getMessage("WARNING_NOT_ALLOWED_TO_BUY_MORE_THAN_IN_STOCK"); } // , "min order" - . $min_order = $obj_product->getProductTagValue('MinQuantity', PRODUCTINFO_NOT_LOCALIZED_DATA); if ($min_order != '' && $min_order > $sum_qty) { $is_error = true; $stock_discarded_by = $msgres->getMessage("ERR_NOT_ALLOWED_TO_BUY_LESS_THAN_MIN_ORDER", array($obj_product->getProductTagValue('MinQuantity'))); } } $colorswatchvalue = modApiFunc('ColorSwatch', 'getColorSwatchInfo', $prod_id); if ($colorswatchvalue != '') { $datacolor = $data['colorname']; if ($datacolor == '') { $is_error = true; $discard_by = 'CLR_SWTCH_ERR_MSG'; } } // // if (!$is_error) { if ($options_sent != "yes") { if ($options_settings['AAWD'] == 'Y') { $data['options'] = modApiFunc("Product_Options", "getDefaultCombinationForEntity", 'product', $prod_id); $check_result = array(); } else { $check_result = array('WRN_ONS'); } } else { list($check_result, $data) = modApiFunc("Product_Options", "checkCombination", $data); } #_print($check_result);die; // if (!empty($check_result)) { $is_error = true; $discard_by = 'WRN_INVALID_OPTIONS'; foreach ($data['options'] as $oinf) { if (is_array($oinf) and array_key_exists('is_file', $oinf) and $oinf['val'] != '') { modApiFunc('Shell', 'removeDirectory', dirname($oinf['val'])); } } } else { $is_error = !modApiFunc("Product_Options", "checkByCRules", 'product', $prod_id, $data['options']); if ($is_error) { $discard_by = 'WRN_CI_CR'; } } //check if the file option can be uploaded (by allowed extensions) See Admin->FILE UPLOAD SETTINGS in admin area if (!$is_error) { $settings = modApiFunc("Settings", "getParamListByGroup", "FILE_UPLOAD_SETTINGS", "SETTINGS_WITH_DESCRIPTION"); $allowed = false; foreach ($data['options'] as $oinf) { if (is_array($oinf) && array_key_exists('is_file', $oinf) && $oinf['val'] != '') { $file_info = pathinfo($oinf['val']); foreach ($settings as $i => $s) { if ($s['param_current_value'] == "YES") { $exts = preg_replace("/, /", "|", $s['description']); $exts = preg_replace("/[.]/", "\\.", $exts); $res = preg_match("/{$exts}/", strtolower($file_info['basename']), $m); if ($res) { // file extension is alowed $allowed = true; break; } else { // not allowed extension $allowed = false; } } } if (!$allowed) { $is_error = true; $discard_by = 'WRN_CI_EXT'; } } } } // Inventory // AANIC - Allow Add the product to the cart Not in Inventory Control if (!$is_error && $options_settings['AANIC'] == 'N' && $stock_method == PRODUCT_OPTIONS_INVENTORY_TRACKING) { $inv_id = modApiFunc("Product_Options", "getInventoryIDByCombination", 'product', $prod_id, $data['options']); if ($inv_id == null) { $is_error = true; $discard_by = 'WRN_CI_INV'; } } // // AANIS - Allow Add the product to the cart Not In Stock if (!$is_error && $options_settings['AANIS'] == 'N' && $stock_method == PRODUCT_OPTIONS_INVENTORY_TRACKING) { $inv_id = modApiFunc("Product_Options", "getInventoryIDByCombination", 'product', $prod_id, $data['options']); if ($inv_id != null) { // , inventory $inv_info = modApiFunc('Product_Options', 'getInventoryInfo', $inv_id); if ($inv_info['quantity'] <= 0 && $use_current_cart) { $is_error = true; $discard_by = 'WRN_CI_INV'; } } } // , , inventory tracking if (!$is_error && $stock_method == PRODUCT_OPTIONS_INVENTORY_TRACKING && $use_current_cart && modApiFunc("Configuration", "getValue", SYSCONFIG_STORE_ALLOW_BUY_MORE_THAN_STOCK) === false) { $inv_id = modApiFunc("Product_Options", "getInventoryIDByCombination", 'product', $prod_id, $data['options']); if ($inv_id != null) { // , $cart_id = $prod_id . "_" . modApiFunc("Product_Options", "getCombinationHash", $data['options']); $obj_cart =& $application->getInstance('Cart'); if (isset($obj_cart->CartContent[$cart_id])) { $qty_already_in_cart = $obj_cart->CartContent[$cart_id]['quantity']; } else { $qty_already_in_cart = 0; } // if ($add_to_cart_add_not_replace === true) { $sum_qty = $qty_already_in_cart + $data['qty']; } else { $sum_qty = $data['qty']; } if ($options_settings['AANIS'] == 'Y') { $inv_info = modApiFunc('Product_Options', 'getInventoryInfo', $inv_id); } if ($options_settings['AANIS'] == 'N' && $inv_info['quantity'] < $sum_qty) { $is_error = true; $stock_discarded_by = $msgres->getMessage("ERR_NOT_ALLOWED_TO_BUY_MORE_THAN_IN_STOCK"); } } } } return array('data' => $data, 'is_error' => $is_error, 'discard_by' => $discard_by, 'stock_discarded_by' => $stock_discarded_by, 'stock_discarded_by_warning' => $stock_discarded_by_warning); }
/** * 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); }
/** * Prepares an email text and the subject to send. */ function prepareEmailTextAndSubject() { global $application; $this->customerEmail = null; $this->product_obj = null; $pushedCurrency = false; switch ($this->actionId) { case '1': case '2': case '3': case '4': case '5': case '16': $pushedCurrency = true; $currencyId = modApiFunc("Localization", "whichCurrencyToDisplayOrderIn", $this->orderId); $orderInfo = modApiFunc("Checkout", "getOrderInfo", $this->orderId, $currencyId); modApiFunc("Localization", "pushDisplayCurrency", $currencyId, $currencyId); $customer_id = $orderInfo['PersonId']; $account_name = modApiFunc('Customer_Account', 'getCustomerAccountNameByCustomerID', $customer_id); $this->customer_obj =& $application->getInstance('CCustomerInfo', $account_name); // $this->customerEmail = $this->customer_obj->getPersonInfo('Email','Customer'); $taxExemptEnabled = modApiFunc('Settings', 'getParamValue', 'TAXES_PARAMS', 'ALLOW_FULL_TAX_EXEMPTS'); $taxExemptInfo = modApiFunc("TaxExempts", "getOrderFullTaxExempts", $this->orderId, false); break; case '6': // if(array_key_exists('Email',$this->customerRegData['info'])) // $this->customerEmail = $this->customerRegData['info']['Email']; $this->customer_obj =& $application->getInstance('CCustomerInfo', $this->customerRegData['account']); break; case '7': case '8': case '9': case '10': case '11': case '12': case '13': $this->customer_obj =& $application->getInstance('CCustomerInfo', $this->customerAccount); // $this->customerEmail = $this->customer_obj->getPersonInfo('Email','Customer'); break; case '14': $this->product_obj =& $application->getInstance('CProductInfo', $this->inventory_info['entity_id']); break; case '15': $this->product_obj =& $application->getInstance('CProductInfo', $this->review_data['product_id']); break; case '18': $this->customer_obj =& $application->getInstance('CCustomerInfo', $this->customerAccount); $this->product_obj =& $application->getInstance('CProductInfo', $this->review_data['product_id']); break; } // reloading the notification info since it may be different for each language $this->getNotificationInfo($this->notificationId); $tagsList = modApiFunc("Notifications", "getAvailableTagsList", array('0' => array('Id' => $this->actionId))); //initialize infotags $infotags = array(); foreach ($tagsList[$this->actionId]['InfoTags'] as $infotag) { if (_ml_strpos($infotag, "Order") == 1) { $tag = _ml_substr($infotag, 6, _ml_strlen($infotag) - 7); switch ($tag) { case 'Date': $infotags[$infotag] = modApiFunc("Localization", "date_format", $orderInfo[$tag]); break; case 'GlobalDiscount': $infotags[$infotag] = modApiFunc("Localization", "currency_format", $orderInfo['Price']['SubtotalGlobalDiscount']); break; case 'PromoCodeDiscount': $infotags[$infotag] = modApiFunc("Localization", "currency_format", $orderInfo['Price']['SubtotalPromoCodeDiscount']); break; case 'QuantityDiscount': $infotags[$infotag] = modApiFunc("Localization", "currency_format", $orderInfo['Price']['QuantityDiscount']); break; case 'DiscountedSubtotal': $infotags[$infotag] = modApiFunc("Localization", "currency_format", $orderInfo['Price']['DiscountedSubtotal']); break; case 'TotalShippingAndHandlingCost': $ShippingCost = $orderInfo['Price']['TotalShippingAndHandlingCost'] == PRICE_N_A ? 0.0 : $orderInfo['Price']['TotalShippingAndHandlingCost']; $infotags[$infotag] = modApiFunc("Localization", "currency_format", $ShippingCost); break; case 'Tax': $infotags[$infotag] = ""; $taxes = array(); foreach ($orderInfo['Price'] as $key => $value) { $tax_name_patern = "/^Taxes\\['(.+)'\\]\$/"; $matches = array(); if (preg_match($tax_name_patern, $key, $matches)) { $taxes[$matches[1]] = $value; } } foreach ($taxes as $name => $value) { $infotags[$infotag] .= $name . " " . modApiFunc("Localization", "currency_format", $value) . "\n"; } break; case 'OldStatus': if ($this->actionId == '2') { $infotags[$infotag] = $this->OrderOldStatus; } break; case 'OldPaymentStatus': if ($this->actionId == '3') { $infotags[$infotag] = $this->OrderOldPaymentStatus; } break; case 'Total': case 'Subtotal': $infotags[$infotag] = modApiFunc("Localization", "currency_format", $orderInfo[$tag]); break; case 'PaymentMethodText': $pm_uid = $orderInfo['PaymentModuleId']; $infotags[$infotag] = modApiFunc("Checkout", "getPaymentMethodText", $pm_uid); break; case "PromoCode": $couponInfo = modApiFunc("PromoCodes", "getOrderCoupons", $this->orderId); if (isset($couponInfo[0]["coupon_promo_code"])) { $infotags[$infotag] = $couponInfo[0]["coupon_promo_code"]; } else { $infotags[$infotag] = ""; } break; case "TaxExptMark": if ($taxExemptEnabled == "true" && isset($taxExemptInfo[0]["exempt_status"]) && $taxExemptInfo[0]["exempt_status"] == "true") { $infotags[$infotag] = getMsg("SYS", "FULL_TAX_EXEMPT_YES_MSG"); } else { $infotags[$infotag] = getMsg("SYS", "FULL_TAX_EXEMPT_NO_MSG"); } break; case "TaxExptAmount": if ($taxExemptEnabled == "true" && isset($taxExemptInfo[0]["exempt_status"]) && $taxExemptInfo[0]["exempt_status"] == "true") { $infotags[$infotag] = modApiFunc("Localization", "currency_format", $orderInfo["Price"]["OrderTaxTotal"]); } else { $infotags[$infotag] = modApiFunc("Localization", "currency_format", "0.0000"); } break; case "TaxExptInput": if ($taxExemptEnabled == "true" && isset($taxExemptInfo[0]["exempt_status"]) && $taxExemptInfo[0]["exempt_status"] == "true") { $infotags[$infotag] = $taxExemptInfo[0]["exempt_reason_customer_input"]; } else { $infotags[$infotag] = ''; } break; case 'OrderTotalToPay': $infotags[$infotag] = modApiFunc("Localization", "currency_format", $orderInfo['Price']['OrderTotalToPay']); break; case 'OrderTotalPrepaidByGC': $infotags[$infotag] = modApiFunc("Localization", "currency_format", $orderInfo['Price']['OrderTotalPrepaidByGC']); break; default: $infotags[$infotag] = $orderInfo[$tag]; break; } } elseif (_ml_strpos($infotag, 'CustomerReview') == 1) { $tag = _ml_substr($infotag, 15, _ml_strlen($infotag) - 16); $tag_value = ''; if ($this->review_data) { switch ($tag) { case 'Date': $tag_value = $this->review_data['date']; break; case 'Time': $tag_value = $this->review_data['time']; break; case 'Author': $tag_value = _ml_substr($this->review_data['author'], 0, 56) . (_ml_strlen($this->review_data['author']) > 56 ? '...' : ''); break; case 'IP': $tag_value = $this->review_data['ip_address']; break; case 'Status': if ($this->review_data['status'] == 'A') { $tag_value = getMsg('CR', 'CR_STATUS_APPROVED'); } elseif ($this->review_data['status'] == 'P') { $tag_value = getMsg('CR', 'CR_STATUS_PENDING'); } else { $tag_value = getMsg('CR', 'CR_STATUS_NOTAPPROVED'); } break; case 'Text': $tag_value = $this->review_data['review']; break; case 'OverallRating': $tag_value = getMsg('CR', 'CR_RECORD_NO_RATE'); if (is_array($this->review_data['rating']) && !empty($this->review_data['rating'])) { $sum = 0; foreach ($this->review_data['rating'] as $v) { $sum += $v['rate']; } $tag_value = sprintf("%.2f", $sum / count($this->review_data['rating'])); } break; } } $infotags[$infotag] = $tag_value; } elseif (_ml_strpos($infotag, "Customer") == 1) { $tag = _ml_substr($infotag, 9, _ml_strlen($infotag) - 10); $infotags[$infotag] = $this->customer_obj->getPersonInfo($tag, 'Customer'); switch (_ml_strtolower($tag)) { case 'country': $infotags[$infotag] = modApiFunc('Location', 'getCountry', $infotags[$infotag]); break; case 'state': if (modApiFunc('Location', 'getStateCode', $infotags[$infotag]) != '') { $infotags[$infotag] = modApiFunc('Location', 'getState', $infotags[$infotag]); } else { $infotags[$infotag] = $infotags[$infotag]; } break; } } elseif (_ml_strpos($infotag, "Shipping") == 1) { $tag = _ml_substr($infotag, 9, _ml_strlen($infotag) - 10); $infotags[$infotag] = isset($orderInfo['Shipping']['attr'][$tag]['value']) ? $orderInfo['Shipping']['attr'][$tag]['value'] : (isset($orderInfo['Shipping']['attr'][$tag . "NULL"]['value']) ? $orderInfo['Shipping']['attr'][$tag . "NULL"]['value'] : ""); } elseif (_ml_strpos($infotag, "Billing") == 1) { $tag = _ml_substr($infotag, 8, _ml_strlen($infotag) - 9); $infotags[$infotag] = isset($orderInfo['Billing']['attr'][$tag]['value']) ? $orderInfo['Billing']['attr'][$tag]['value'] : ""; } elseif (_ml_strpos($infotag, "StoreOwner") == 1) { $tag = _ml_substr($infotag, 11, _ml_strlen($infotag) - 12); switch ($tag) { case "StreetLine1": $infotags[$infotag] = modApiFunc("Configuration", "getValue", "store_owner_street_line_1"); break; case "StreetLine2": $infotags[$infotag] = modApiFunc("Configuration", "getValue", "store_owner_street_line_2"); break; case "SiteAdministratorEmail": $infotags[$infotag] = modApiFunc("Configuration", "getValue", "store_owner_site_administrator_email"); break; case "OrdersDepartmentEmail": $infotags[$infotag] = modApiFunc("Configuration", "getValue", "store_owner_orders_department_email"); break; case "Country": $infotags[$infotag] = modApiFunc("Location", "getCountry", modApiFunc("Configuration", "getValue", "store_owner_country")); break; case "State": $state = modApiFunc("Configuration", "getValue", "store_owner_state"); $states_in_country = modApiFunc("Location", "getStates", modApiFunc("Configuration", "getValue", "store_owner_country")); if (array_key_exists($state, $states_in_country)) { $infotags[$infotag] = modApiFunc("Location", "getState", $state); } else { $infotags[$infotag] = $state; } break; default: $infotags[$infotag] = modApiFunc("Configuration", "getValue", "store_owner_" . _ml_strtolower($tag)); break; } } elseif (_ml_strpos($infotag, "TrackingNumber") == 1) { $infotags[$infotag] = $orderInfo["TrackId"]; } elseif (_ml_strpos($infotag, 'AccountActivationLink') == 1) { $r = new Request(); $r->setView('AccountActivation'); $r->setAction('activate_account'); $r->setKey('key', modApiFunc('Customer_Account', 'getActivationKey', $this->customerAccount)); $infotags[$infotag] = $r->getURL(); } elseif (_ml_strpos($infotag, 'AccountName') == 1) { $infotags[$infotag] = $this->customerAccount; } elseif (_ml_strpos($infotag, 'AccountNewPasswordLink') == 1) { $cz_layouts = LayoutConfigurationManager::static_get_cz_layouts_list(); LayoutConfigurationManager::static_activate_cz_layout(array_shift(array_keys($cz_layouts))); $r = new CZRequest(); $r->setView('CustomerNewPassword'); $r->setKey('key', modApiFunc('Customer_Account', 'getActivationKey', $this->customerAccount)); $infotags[$infotag] = $r->getURL(); } elseif (preg_match('/^\\{combination(.+)\\}$/i', $infotag, $matches)) { $tag_value = ''; switch (_ml_strtolower($matches[1])) { case 'sku': $tag_value = $this->inventory_info['sku']; break; case 'quantityinstock': $tag_value = $this->inventory_info['quantity']; break; case 'description': $tag_value = modApiFunc('Product_Options', 'convertCombinationToString', modApiFunc('Product_Options', '_unserialize_combination', $this->inventory_info['combination']), '; '); break; default: $tag_value = ''; break; } $infotags[$infotag] = $tag_value; } elseif (preg_match('/^\\{product(.+)\\}$/i', $infotag, $matches) and $this->product_obj != null) { $infotags[$infotag] = $this->product_obj->getProductTagValue($matches[1], PRODUCTINFO_LOCALIZED_DATA); } elseif (_ml_strpos($infotag, 'GiftCertificateRecipient') == 1) { if ($this->gift_cert != null) { $infotags[$infotag] = $this->gift_cert->to; } } } //initialize blocktags foreach ($tagsList[$this->actionId]['BlockTags'] as $blocktagId => $blocktagInfo) { $infotags[$blocktagInfo['BlockTag']] = ""; switch ($blocktagInfo['BlockTag']) { case '{OrderContentBlock}': foreach ($orderInfo['Products'] as $productInfo) { # settings default values for all infotags foreach ($blocktagInfo['BlockInfoTags'] as $t) { $t = strtr($t, array('{' => '\\{', '}' => '\\}')); $init_productInfoTags[$t] = ""; } $productInfoTags = array("{ProductID}" => $productInfo['storeProductID'], "{ProductName}" => $productInfo['name'], "{ProductQuantity}" => $productInfo['qty'], "{ProductPrice}" => modApiFunc("Localization", "currency_format", $productInfo['SalePrice']), "{ProductAmount}" => modApiFunc("Localization", "currency_format", $productInfo['qty'] * $productInfo['SalePrice']), "{ProductOptions}" => modApiFunc("Product_Options", "prepareTextForNotificaton", $productInfo['options'])); $productInfoTags = array_merge($init_productInfoTags, $productInfoTags); foreach ($productInfo['attr'] as $attr => $attr_value) { if ($attr == "SalePrice" || $attr == "ListPrice" || $attr == "PerItemShippingCost" || $attr == "PerItemHandlingCost") { $productInfoTags["{Product" . $attr . "}"] = modApiFunc("Localization", "currency_format", $attr_value["value"]); } elseif ($attr == "FreeShipping" || $attr == "NeedShipping") { $productInfoTags["{Product" . $attr . "}"] = $attr_value["value"] == PRODUCT_FREESHIPPING_YES ? $this->MessageResources->getMessage("NTFCTN_INFO_YES_LABEL") : $this->MessageResources->getMessage("NTFCTN_INFO_NO_LABEL"); } else { $productInfoTags["{Product" . $attr . "}"] = $attr_value["value"]; } } foreach ($productInfo['custom_attributes'] as $custom_attr_info) { $productInfoTags["{Product" . $custom_attr_info["tag"] . "Custom}"] = $custom_attr_info["value"]; } $blocktag_body = $this->getNotificationBlockBody($blocktagId); foreach ($productInfoTags as $tag => $val) { $blocktag_body = str_ireplace($tag, $val, $blocktag_body); } $infotags[$blocktagInfo['BlockTag']] .= $blocktag_body . "\n"; } break; case '{LowLevelProductsBlock}': foreach ($orderInfo['Products'] as $productInfo) { if (!in_array($productInfo['storeProductID'], $this->_LowLevelProducts)) { continue; } $_productInfo = new CProductInfo($productInfo['storeProductID']); if ($_productInfo->whichStockControlMethod() == PRODUCT_OPTIONS_INVENTORY_TRACKING) { $productQuantityInStock = modApiFunc('Product_Options', 'getQuantityInStockByInventoryTable', 'product', $productInfo['storeProductID']); } else { $productQuantityInStock = $_productInfo->getProductTagValue('QuantityInStock', PRODUCTINFO_NOT_LOCALIZED_DATA); } $productLowLevelInStock = $_productInfo->getProductTagValue('LowStockLevel', PRODUCTINFO_NOT_LOCALIZED_DATA); $productInfoTags = array("{ProductID}" => $productInfo['storeProductID'], "{ProductName}" => $productInfo['name'], "{ProductPrice}" => modApiFunc("Localization", "currency_format", $productInfo['SalePrice']), "{ProductQuantityInStock}" => (string) $productQuantityInStock); foreach ($productInfo['attr'] as $attr => $attr_value) { if ($attr == "SalePrice" || $attr == "ListPrice" || $attr == "PerItemShippingCost" || $attr == "PerItemHandlingCost") { $productInfoTags["{Product" . $attr . "}"] = modApiFunc("Localization", "currency_format", $attr_value["value"]); } elseif ($attr == "FreeShipping" || $attr == "NeedShipping") { $productInfoTags["{Product" . $attr . "}"] = $attr_value["value"] == PRODUCT_FREESHIPPING_YES ? $this->MessageResources->getMessage("NTFCTN_INFO_YES_LABEL") : $this->MessageResources->getMessage("NTFCTN_INFO_NO_LABEL"); } else { if ($attr != "QuantityInStock") { $productInfoTags["{Product" . $attr . "}"] = $attr_value["value"]; } } } foreach ($productInfo['custom_attributes'] as $custom_attr_info) { $productInfoTags["{Product" . $custom_attr_info["tag"] . "Custom}"] = $custom_attr_info["value"]; } $blocktag_body = $this->getNotificationBlockBody($blocktagId); foreach ($productInfoTags as $tag => $val) { $blocktag_body = str_ireplace($tag, $val, $blocktag_body); } $infotags[$blocktagInfo['BlockTag']] .= $blocktag_body . "\n"; } break; case '{OrderDiscountsBlock}': $promoInfo = modApiFunc("PromoCodes", "getOrderCoupons", $this->orderId); $promoCode = isset($promoInfo[0]["coupon_promo_code"]) ? $promoInfo[0]["coupon_promo_code"] : ""; $discountsInfoTags = array("{OrderGlobalDiscount}" => modApiFunc("Localization", "currency_format", $orderInfo['Price']['SubtotalGlobalDiscount']), "{OrderPromoCode}" => $promoCode, "{OrderPromoCodeDiscount}" => modApiFunc("Localization", "currency_format", $orderInfo['Price']['SubtotalPromoCodeDiscount']), "{OrderQuantityDiscount}" => modApiFunc("Localization", "currency_format", $orderInfo['Price']['QuantityDiscount']), "{OrderDiscountedSubtotal}" => modApiFunc("Localization", "currency_format", $orderInfo['Price']['DiscountedSubtotal']), "{OrderSubtotal}" => modApiFunc("Localization", "currency_format", $orderInfo['Price']['OrderSubtotal']), "{OrderTotalToPay}" => modApiFunc("Localization", "currency_format", $orderInfo['Price']['OrderTotalToPay']), "{OrderTotalPrepaidByGC}" => modApiFunc("Localization", "currency_format", $orderInfo['Price']['OrderTotalPrepaidByGC'])); $blocktag_body = $this->getNotificationBlockBody($blocktagId); foreach ($discountsInfoTags as $tag => $val) { $blocktag_body = str_ireplace($tag, $val, $blocktag_body); } $infotags[$blocktagInfo['BlockTag']] .= $blocktag_body; break; case '{OrderDownloadLinksBlock}': $hotlinks = modApiFunc('Product_Files', 'getHotlinksListForOrder', $this->orderId); foreach ($hotlinks as $k => $hotlink_info) { $file_info = modApiFunc('Product_Files', 'getPFileInfo', $hotlink_info['file_id']); $HotlinkInfoTags = array("{DownloadLink}" => $hotlink_info['hotlink_value'], "{DownloadLinkExpiryDate}" => date("d M Y, H:i", $hotlink_info['expire_date']), "{DownloadLinkAttempts}" => $hotlink_info['max_try'], "{DownloadFilename}" => $file_info['file_name'], "{DownloadFileDescription}" => $file_info['file_descr']); $blocktag_body = $this->getNotificationBlockBody($blocktagId); foreach ($HotlinkInfoTags as $tag => $val) { $blocktag_body = str_ireplace($tag, $val, $blocktag_body); } $infotags[$blocktagInfo['BlockTag']] .= $blocktag_body; } break; case '{OrderedGiftCertificateBlock}': $gcs = array(); if ($this->gift_cert) { $gcs = array(modApiFunc("GiftCertificateApi", "getGiftCertificate", $this->gift_cert->code)); } else { if ($this->orderId) { $gcs = modApiFunc("GiftCertificateApi", "getGiftCertificatesForOrderId", $this->orderId); } } if (sizeof($gcs) > 0) { foreach ($gcs as $gc) { $GCInfoTags = array("{PurchasedGiftCertificateCode}" => $gc["gc_code"], "{PurchasedGiftCertificateMessage}" => $gc["gc_message"], "{PurchasedGiftCertificateAmount}" => modApiFunc("Localization", "currency_format", $gc["gc_amount"]), "{PurchasedGiftCertificateFrom}" => $gc["gc_from"], "{PurchasedGiftCertificateTo}" => $gc["gc_to"], "{PurchasedGiftCertificateType}" => $gc["gc_sendtype"]); $blocktag_body = $this->getNotificationBlockBody($blocktagId); foreach ($GCInfoTags as $tag => $val) { $blocktag_body = str_replace($tag, $val, $blocktag_body); } $infotags[$blocktagInfo['BlockTag']] .= $blocktag_body; } } break; case '{AppliedGiftCertificateBlock}': $gcs = modApiFunc("GiftCertificateApi", "getOrderGCs", $this->orderId); if (!empty($gcs) && is_array($gcs)) { foreach ($gcs as $i => $gc_data) { $gc = new GiftCertificate($gc_data['gc_code']); $GCInfoTags = array("{AppliedGiftCertificateCode}" => $gc->code, "{AppliedGiftCertificateMessage}" => $gc->message, "{AppliedGiftCertificateAmount}" => modApiFunc("Localization", "currency_format", $gc->amount), "{AppliedGiftCertificateFrom}" => $gc->from, "{AppliedGiftCertificateTo}" => $gc->to, "{AppliedGiftCertificateType}" => $gc->sendtype); $blocktag_body = $this->getNotificationBlockBody($blocktagId); foreach ($GCInfoTags as $tag => $val) { $blocktag_body = str_replace($tag, $val, $blocktag_body); } $infotags[$blocktagInfo['BlockTag']] .= $blocktag_body; } } break; } } $this->EmailText = $this->getNotificationBody(); $this->EmailSubject = $this->subject; foreach ($infotags as $tag => $val) { $this->EmailText = str_ireplace($tag, $val, $this->EmailText); $this->EmailSubject = str_ireplace($tag, $val, $this->EmailSubject); } $this->EmailText = $this->html_replace($this->EmailText); $this->EmailSubject = $this->html_replace($this->EmailSubject); if ($pushedCurrency) { modApiFunc("Localization", "popDisplayCurrency"); } }