$linked_categories = array(); foreach ($affiliate_plan['category_ids'] as $cat_id => $sale) { $linked_categories[$cat_id]['category'] = fn_get_category_name($cat_id, DESCR_SL); $linked_categories[$cat_id]['category_id'] = $cat_id; $linked_categories[$cat_id]['sale'] = $sale; } $view->assign('linked_categories', $linked_categories); $params = array('promotion_id' => empty($affiliate_plan['promotion_ids']) ? array('0' => 0) : array_keys($affiliate_plan['promotion_ids'])); list($affiliate_plan['coupons']) = fn_get_promotions($params); foreach ($affiliate_plan['coupons'] as $promotion_id => $coupon_data) { if (isset($affiliate_plan['promotion_ids'][$promotion_id])) { $affiliate_plan['coupons'][$promotion_id]['use_coupon'] = $affiliate_plan['promotion_ids'][$promotion_id]; } } $params = array('coupons' => true); list($coupons) = fn_get_promotions($params); foreach (array_keys($affiliate_plan['promotion_ids']) as $promotion_id) { unset($coupons[$promotion_id]); } $view->assign('coupons', $coupons); $view->assign('affiliate_plan', $affiliate_plan); $view->assign('payout_types', Registry::get('payout_types')); } elseif ($mode == 'add') { // [Breadcrumbs] fn_add_breadcrumb(fn_get_lang_var('plans'), "affiliate_plans.manage"); // [/Breadcrumbs] // [Page sections] Registry::set('navigation.tabs', array('general' => array('title' => fn_get_lang_var('general'), 'js' => true), 'linked_products' => array('title' => fn_get_lang_var('products'), 'js' => true), 'linked_categories' => array('title' => fn_get_lang_var('categories'), 'js' => true), 'coupons' => array('title' => fn_get_lang_var('coupons'), 'js' => true), 'multi_tier_affiliates' => array('title' => fn_get_lang_var('multi_tier_affiliates'), 'js' => true))); // [/Page sections] $view->assign('payout_types', Registry::get('payout_types')); } elseif ($mode == 'manage') {
/** * Pre/Post coupon checking/applying * * @param array $cart cart * @param boolean $initial_check true for pre-check, false - for post-check * @param array $applied_promotions list of applied promotions * @return boolean true if coupon is applied, false - otherwise */ function fn_promotion_check_coupon(&$cart, $initial_check, $applied_promotions = array()) { $result = true; // Pre-check: find if coupon is already used or only single coupon is allowed if ($initial_check == true) { fn_set_hook('pre_promotion_check_coupon', $cart['pending_coupon'], $cart); if (!empty($cart['coupons'][$cart['pending_coupon']])) { $_SESSION['promotion_notices']['promotion']['messages'][] = 'coupon_already_used'; unset($cart['pending_coupon']); $result = false; } elseif (Registry::get('settings.General.use_single_coupon') == 'Y' && sizeof($cart['coupons']) > 0) { $_SESSION['promotion_notices']['promotion']['messages'][] = 'single_coupon_is_allowed'; unset($cart['pending_coupon']); $result = false; } else { $cart['coupons'][$cart['pending_coupon']] = true; } // Post-check: check if coupon was applied successfully } else { if (!empty($cart['pending_coupon'])) { if (!empty($applied_promotions)) { $params = array('active' => true, 'coupon_code' => !empty($cart['pending_original_coupon']) ? $cart['pending_original_coupon'] : $cart['pending_coupon'], 'promotion_id' => array_keys($applied_promotions)); list($coupon) = fn_get_promotions($params); } if (empty($coupon)) { if (!fn_notification_exists('extra', 'error_coupon_already_used')) { $_SESSION['promotion_notices']['promotion']['messages'][] = 'no_such_coupon'; } unset($cart['coupons'][$cart['pending_coupon']]); $result = false; } else { $cart['coupons'][$cart['pending_coupon']] = array_keys($coupon); fn_set_hook('promotion_check_coupon', $cart['pending_coupon'], $cart); } unset($cart['pending_coupon'], $cart['pending_original_coupon']); } } return $result; }
Registry::get('view')->assign('prefix', $_REQUEST['prefix']); Registry::get('view')->assign('elm_id', $_REQUEST['elm_id']); if (!empty($_REQUEST['zone'])) { Registry::get('view')->assign('zone', $_REQUEST['zone']); } if (!empty($_REQUEST['condition'])) { Registry::get('view')->assign('condition_data', array('condition' => $_REQUEST['condition'])); } elseif (!empty($_REQUEST['bonus'])) { Registry::get('view')->assign('bonus_data', array('bonus' => $_REQUEST['bonus'])); } if (fn_allowed_for('ULTIMATE') && !Registry::get('runtime.company_id')) { Registry::get('view')->assign('picker_selected_companies', fn_ult_get_controller_shared_companies($_REQUEST['promotion_id'], 'promotions', 'update')); } // promotions list } elseif ($mode == 'manage') { list($promotions, $search) = fn_get_promotions($_REQUEST, Registry::get('settings.Appearance.admin_elements_per_page'), DESCR_SL); Registry::get('view')->assign('search', $search); Registry::get('view')->assign('promotions', $promotions); // Delete selected promotions } elseif ($mode == 'delete') { if (!empty($_REQUEST['promotion_id'])) { fn_delete_promotions($_REQUEST['promotion_id']); } return array(CONTROLLER_STATUS_REDIRECT, "promotions.manage"); } function fn_update_promotion($data, $promotion_id, $lang_code = DESCR_SL) { if (!empty($data['conditions']['conditions'])) { $data['conditions_hash'] = fn_promotion_serialize($data['conditions']['conditions']); $data['users_conditions_hash'] = fn_promotion_serialize_users_conditions($data['conditions']['conditions']); } else {
function fn_get_order_info($order_id, $native_language = false, $format_info = true, $get_edp_files = false, $skip_static_values = false) { if (!empty($order_id)) { $condition = fn_get_company_condition('?:orders.company_id'); $order = db_get_row("SELECT * FROM ?:orders WHERE ?:orders.order_id = ?i {$condition}", $order_id); if (!empty($order)) { $lang_code = $native_language == true ? $order['lang_code'] : CART_LANGUAGE; if (isset($order['ip_address'])) { $order['ip_address'] = fn_ip_from_db($order['ip_address']); } $order['payment_method'] = fn_get_payment_method_data($order['payment_id'], $lang_code); // Get additional profile fields $additional_fields = db_get_hash_single_array("SELECT field_id, value FROM ?:profile_fields_data " . "WHERE object_id = ?i AND object_type = 'O'", array('field_id', 'value'), $order_id); $order['fields'] = $additional_fields; $order['products'] = db_get_hash_array("SELECT ?:order_details.*, ?:product_descriptions.product, ?:products.status as product_status FROM ?:order_details " . "LEFT JOIN ?:product_descriptions ON ?:order_details.product_id = ?:product_descriptions.product_id AND ?:product_descriptions.lang_code = ?s " . "LEFT JOIN ?:products ON ?:order_details.product_id = ?:products.product_id " . "WHERE ?:order_details.order_id = ?i ORDER BY ?:product_descriptions.product", 'item_id', $lang_code, $order_id); $order['promotions'] = unserialize($order['promotions']); if (!empty($order['promotions'])) { // collect additional data $params = array('promotion_id' => array_keys($order['promotions'])); list($promotions) = fn_get_promotions($params); foreach ($promotions as $pr_id => $p) { $order['promotions'][$pr_id]['name'] = $p['name']; $order['promotions'][$pr_id]['short_description'] = $p['short_description']; } } // Get additional data $additional_data = db_get_hash_single_array("SELECT type, data FROM ?:order_data WHERE order_id = ?i", array('type', 'data'), $order_id); $order['taxes'] = array(); $order['tax_subtotal'] = 0; $order['display_shipping_cost'] = $order['shipping_cost']; // Replace country, state and title values with their descriptions $order_company_id = isset($order['company_id']) ? $order['company_id'] : ''; // company_id will be rewritten by user field, so need to save it. fn_add_user_data_descriptions($order, $lang_code); $order['company_id'] = $order_company_id; $order['need_shipping'] = false; $deps = array(); // Get shipping information if (!empty($additional_data['L'])) { $order['shipping'] = unserialize($additional_data['L']); foreach ($order['shipping'] as $key => $v) { $shipping_id = isset($v['shipping_id']) ? $v['shipping_id'] : 0; $shipping_name = fn_get_shipping_name($shipping_id, $lang_code); if ($shipping_name) { $order['shipping'][$key]['shipping'] = $shipping_name; } } } if (!fn_allowed_for('ULTIMATE:FREE')) { // Get shipments common information $order['shipment_ids'] = db_get_fields("SELECT sh.shipment_id FROM ?:shipments AS sh LEFT JOIN ?:shipment_items AS s_items ON (sh.shipment_id = s_items.shipment_id) " . "WHERE s_items.order_id = ?i GROUP BY s_items.shipment_id", $order_id); $_products = db_get_array("SELECT item_id, SUM(amount) AS amount FROM ?:shipment_items WHERE order_id = ?i GROUP BY item_id", $order_id); $shipped_products = array(); if (!empty($_products)) { foreach ($_products as $_product) { $shipped_products[$_product['item_id']] = $_product['amount']; } } unset($_products); } foreach ($order['products'] as $k => $v) { //Check for product existance if (empty($v['product'])) { $order['products'][$k]['deleted_product'] = true; } else { $order['products'][$k]['deleted_product'] = false; } $order['products'][$k]['discount'] = 0; $v['extra'] = @unserialize($v['extra']); if ($order['products'][$k]['deleted_product'] == true && !empty($v['extra']['product'])) { $order['products'][$k]['product'] = $v['extra']['product']; } else { $order['products'][$k]['product'] = fn_get_product_name($v['product_id'], $lang_code); } $order['products'][$k]['company_id'] = empty($v['extra']['company_id']) ? 0 : $v['extra']['company_id']; if (!empty($v['extra']['discount']) && floatval($v['extra']['discount'])) { $order['products'][$k]['discount'] = $v['extra']['discount']; $order['use_discount'] = true; } if (!empty($v['extra']['promotions'])) { $order['products'][$k]['promotions'] = $v['extra']['promotions']; } if (isset($v['extra']['base_price'])) { $order['products'][$k]['base_price'] = floatval($v['extra']['base_price']); } else { $order['products'][$k]['base_price'] = $v['price']; } $order['products'][$k]['original_price'] = $order['products'][$k]['base_price']; // Form hash key for this product $order['products'][$k]['cart_id'] = $v['item_id']; $deps['P_' . $order['products'][$k]['cart_id']] = $k; // Unserialize and collect product options information if (!empty($v['extra']['product_options'])) { if ($format_info == true) { if (!empty($v['extra']['product_options_value'])) { $order['products'][$k]['product_options'] = $v['extra']['product_options_value']; } else { $order['products'][$k]['product_options'] = fn_get_selected_product_options_info($v['extra']['product_options'], $lang_code); } } $product_options_value = $skip_static_values == false && !empty($v['extra']['product_options_value']) ? $v['extra']['product_options_value'] : array(); if (empty($v['extra']['stored_price']) || !empty($v['extra']['stored_price']) && $v['extra']['stored_price'] != 'Y') { // apply modifiers if this is not the custom price $order['products'][$k]['original_price'] = fn_apply_options_modifiers($v['extra']['product_options'], $order['products'][$k]['base_price'], 'P', $product_options_value, array('product_data' => $v)); } } $order['products'][$k]['extra'] = $v['extra']; $order['products'][$k]['tax_value'] = 0; $order['products'][$k]['display_subtotal'] = $order['products'][$k]['subtotal'] = $v['price'] * $v['amount']; // Get information about edp if ($get_edp_files == true && $order['products'][$k]['extra']['is_edp'] == 'Y') { $order['products'][$k]['files'] = db_get_array("SELECT ?:product_files.file_id, ?:product_files.activation_type, ?:product_files.max_downloads, " . "?:product_file_descriptions.file_name, ?:product_file_ekeys.active, ?:product_file_ekeys.downloads, " . "?:product_file_ekeys.ekey, ?:product_file_ekeys.ttl FROM ?:product_files " . "LEFT JOIN ?:product_file_descriptions ON ?:product_file_descriptions.file_id = ?:product_files.file_id " . "AND ?:product_file_descriptions.lang_code = ?s " . "LEFT JOIN ?:product_file_ekeys ON ?:product_file_ekeys.file_id = ?:product_files.file_id " . "AND ?:product_file_ekeys.order_id = ?i WHERE ?:product_files.product_id = ?i", $lang_code, $order_id, $v['product_id']); } // Get shipments information // If current edition is FREE, we still need to check shipments accessibility (need to display promotion link) if (isset($shipped_products[$k])) { $order['products'][$k]['shipped_amount'] = $shipped_products[$k]; $order['products'][$k]['shipment_amount'] = $v['amount'] - $shipped_products[$k]; } else { $order['products'][$k]['shipped_amount'] = 0; $order['products'][$k]['shipment_amount'] = $v['amount']; } if ($order['products'][$k]['shipped_amount'] < $order['products'][$k]['amount']) { if (!empty($order['shipping'])) { $group_key = empty($v['extra']['group_key']) ? 0 : $v['extra']['group_key']; $order['shipping'][$group_key]['need_shipment'] = true; } else { $order['need_shipment'] = true; } } // Check if the order needs the shipping method if (!($v['extra']['is_edp'] == 'Y' && (!isset($v['extra']['edp_shipping']) || $v['extra']['edp_shipping'] != 'Y'))) { $order['need_shipping'] = true; } // Adds flag that defines if product page is available $order['products'][$k]['is_accessible'] = fn_is_accessible_product($v); fn_set_hook('get_order_items_info_post', $order, $v, $k); } // Unserialize and collect taxes information if (!empty($additional_data['T'])) { $order['taxes'] = unserialize($additional_data['T']); if (is_array($order['taxes'])) { foreach ($order['taxes'] as $tax_id => $tax_data) { if (Registry::get('settings.General.tax_calculation') == 'unit_price') { foreach ($tax_data['applies'] as $_id => $value) { if (strpos($_id, 'P_') !== false && isset($deps[$_id])) { $order['products'][$deps[$_id]]['tax_value'] += $value; if ($tax_data['price_includes_tax'] != 'Y') { $order['products'][$deps[$_id]]['subtotal'] += $value; $order['products'][$deps[$_id]]['display_subtotal'] += Registry::get('settings.Appearance.cart_prices_w_taxes') == 'Y' ? $value : 0; } } if (strpos($_id, 'S_') !== false) { if ($tax_data['price_includes_tax'] != 'Y') { $order['shipping_cost'] += $value; $order['display_shipping_cost'] += Registry::get('settings.Appearance.cart_prices_w_taxes') == 'Y' ? $value : 0; } } } } if ($tax_data['price_includes_tax'] != 'Y') { $order['tax_subtotal'] += $tax_data['tax_subtotal']; } } } else { $order['taxes'] = array(); } } if (!empty($additional_data['C'])) { $order['coupons'] = unserialize($additional_data['C']); } if (!empty($additional_data['R'])) { $order['secondary_currency'] = unserialize($additional_data['R']); } if (!empty($order['issuer_id'])) { $order['issuer_data'] = fn_get_user_short_info($order['issuer_id']); } // Recalculate subtotal $order['subtotal'] = $order['display_subtotal'] = 0; foreach ($order['products'] as $v) { $order['subtotal'] += $v['subtotal']; $order['display_subtotal'] += $v['display_subtotal']; } // Unserialize and collect payment information if (!empty($additional_data['P'])) { $order['payment_info'] = unserialize(fn_decrypt_text($additional_data['P'])); } if (empty($order['payment_info']) || !is_array($order['payment_info'])) { $order['payment_info'] = array(); } // Get shipping information if (!empty($additional_data['G'])) { $order['product_groups'] = unserialize($additional_data['G']); } $order['doc_ids'] = db_get_hash_single_array("SELECT type, doc_id FROM ?:order_docs WHERE order_id = ?i", array('type', 'doc_id'), $order_id); } fn_set_hook('get_order_info', $order, $additional_data); return $order; } return false; }
function fn_affiliate_pre_promotion_check_coupon(&$coupon_code) { if (empty($coupon_code) || !defined('CHECKOUT')) { return false; } $orig_coupon = $coupon_code; $prefix = Registry::get('addons.affiliate.coupon_prefix_delim'); $delim_len = strlen($prefix); if (Registry::get('addons.affiliate.use_affiliate_id') == 'Y' && !empty($delim_len)) { if (($delim_idx = strpos($coupon_code, $prefix)) != false) { $delim_chr = substr($coupon_code, $delim_idx, $delim_len); if ($delim_chr == $prefix) { $partner_id = intval(substr($coupon_code, 0, $delim_idx)); if (!empty($partner_id)) { $coupon_code = substr($coupon_code, $delim_idx + $delim_len); } } } } else { $prefix_length = 10; $delim_chr = substr($coupon_code, $prefix_length, $delim_len); if ($delim_chr == $prefix) { $partner_code = substr($coupon_code, 0, $prefix_length); $partner_id = fn_any2dec($partner_code); if (!empty($partner_id)) { if ($partner_code == fn_dec2any($partner_id)) { $coupon_code = substr($coupon_code, $prefix_length + $delim_len); } else { $partner_id = 0; } } } } if (!empty($partner_id)) { $plans_data = fn_get_affiliate_plan_data_by_partner_id($partner_id, true); $valid_coupon = false; if (!empty($plans_data['promotion_ids'])) { $params = array('promotion_id' => array_keys($plans_data['promotion_ids']), 'expand' => true); list($coupons) = fn_get_promotions($params); foreach ($coupons as $coupon_data) { foreach ($coupon_data['conditions']['conditions'] as $cnd) { if ($cnd['condition'] == 'coupon_code' && $coupon_code == $cnd['value']) { $valid_coupon = true; break; } } if ($valid_coupon) { break; } } } if (!$valid_coupon) { $partner_id = 0; $coupon_code = $orig_coupon; } } if (!empty($partner_id)) { Registry::set('affiliate_partner_id', $partner_id); return true; } else { return false; } }
function fn_get_order_info($order_id, $native_language = false, $format_info = true, $get_edp_files = false, $skip_static_values = false) { if (!empty($order_id)) { $condition = fn_get_company_condition(); $order = db_get_row("SELECT * FROM ?:orders WHERE ?:orders.order_id = ?i {$condition}", $order_id); if (empty($order)) { return false; } $lang_code = $native_language == true ? $order['lang_code'] : CART_LANGUAGE; $order['payment_method'] = fn_get_payment_method_data($order['payment_id'], $lang_code); if (!empty($order)) { // Get additional profile fields $additional_fields = db_get_hash_single_array("SELECT field_id, value FROM ?:profile_fields_data WHERE object_id = ?i AND object_type = 'O'", array('field_id', 'value'), $order_id); $order['fields'] = $additional_fields; $order['items'] = db_get_hash_array("SELECT ?:order_details.*, ?:product_descriptions.product, ?:product_descriptions.short_description FROM ?:order_details LEFT JOIN ?:product_descriptions ON ?:order_details.product_id = ?:product_descriptions.product_id AND ?:product_descriptions.lang_code = ?s WHERE ?:order_details.order_id = ?i ORDER BY ?:product_descriptions.product", 'item_id', $lang_code, $order_id); $order['promotions'] = unserialize($order['promotions']); if (!empty($order['promotions'])) { // collect additional data $params = array('promotion_id' => array_keys($order['promotions'])); list($promotions) = fn_get_promotions($params); foreach ($promotions as $pr_id => $p) { $order['promotions'][$pr_id]['name'] = $p['name']; $order['promotions'][$pr_id]['short_description'] = $p['short_description']; } } // Get additional data $additional_data = db_get_hash_single_array("SELECT type, data FROM ?:order_data WHERE order_id = ?i", array('type', 'data'), $order_id); $order['taxes'] = array(); $order['tax_subtotal'] = 0; $order['display_shipping_cost'] = $order['shipping_cost']; // Replace country, state and title values with their descriptions fn_add_user_data_descriptions($order, $lang_code); $order['need_shipping'] = false; $deps = array(); // Get shipments common information if (Registry::get('settings.General.use_shipments') == 'Y') { $order['shipment_ids'] = db_get_fields('SELECT sh.shipment_id FROM ?:shipments AS sh LEFT JOIN ?:shipment_items AS s_items ON (sh.shipment_id = s_items.shipment_id) WHERE s_items.order_id = ?i GROUP BY s_items.shipment_id', $order_id); $_products = db_get_array("SELECT item_id, SUM(amount) AS amount FROM ?:shipment_items WHERE order_id = ?i GROUP BY item_id", $order_id); $shipped_products = array(); if (!empty($_products)) { foreach ($_products as $_product) { $shipped_products[$_product['item_id']] = $_product['amount']; } } unset($_products); } foreach ($order['items'] as $k => $v) { //Check for product existance if (empty($v['product'])) { $order['items'][$k]['deleted_product'] = true; } $order['items'][$k]['discount'] = 0; $v['extra'] = @unserialize($v['extra']); if ($skip_static_values == false && !empty($v['extra']['product'])) { $order['items'][$k]['product'] = $v['extra']['product']; preg_match("/\\[(.*?)\\]/", $v['extra']['product'], $resmath); $order['items'][$k]['art'] = $resmath[1]; } $order['items'][$k]['company_id'] = empty($v['extra']['company_id']) ? 0 : $v['extra']['company_id']; if (!empty($v['extra']['discount']) && floatval($v['extra']['discount'])) { $order['items'][$k]['discount'] = $v['extra']['discount']; $order['use_discount'] = true; } if (!empty($v['extra']['promotions'])) { $order['items'][$k]['promotions'] = $v['extra']['promotions']; } if (isset($v['extra']['base_price'])) { $order['items'][$k]['base_price'] = floatval($v['extra']['base_price']); } else { $order['items'][$k]['base_price'] = $v['price']; } $order['items'][$k]['original_price'] = $order['items'][$k]['base_price']; // Form hash key for this product $order['items'][$k]['cart_id'] = $v['item_id']; $deps['P_' . $order['items'][$k]['cart_id']] = $k; //$order['items'][$k]['sklad'] = fn_numsklad($order['items'][$k]['product']); // Unserialize and collect product options information if (!empty($v['extra']['product_options'])) { if ($format_info == true) { $order['items'][$k]['product_options'] = $skip_static_values == false && !empty($v['extra']['product_options_value']) ? $v['extra']['product_options_value'] : fn_get_selected_product_options_info($v['extra']['product_options'], $lang_code); } if (empty($v['extra']['stored_price'])) { // apply modifiers if this is not the custom price $order['items'][$k]['original_price'] = fn_apply_options_modifiers($v['extra']['product_options'], $order['items'][$k]['base_price'], 'P', $skip_static_values == false && !empty($v['extra']['product_options_value']) ? $v['extra']['product_options_value'] : array()); } } $img = db_get_field("SELECT cscart_images.image_path FROM cscart_images_links LEFT \nJOIN cscart_images ON cscart_images_links.image_id = cscart_images.image_id \nWHERE cscart_images_links.object_id = ?i", $order['items'][$k]['product_id']); $imgid = db_get_field("SELECT cscart_images_links.image_id FROM cscart_images_links \nWHERE cscart_images_links.object_id = ?i", $order['items'][$k]['product_id']); $order['items'][$k]['extra'] = $v['extra']; $order['items'][$k]['img'] = fn_get_image($imgid, "product"); $order['items'][$k]['tax_value'] = 0; $order['items'][$k]['display_subtotal'] = $order['items'][$k]['subtotal'] = $v['price'] * $v['amount']; $order['items'][$k]['display_per_subtotal'] = $order['items'][$k]['original_price'] * $v['amount']; // Get information about edp if ($get_edp_files == true && $order['items'][$k]['extra']['is_edp'] == 'Y') { $order['items'][$k]['files'] = db_get_array("SELECT ?:product_files.file_id, ?:product_files.activation_type, ?:product_files.max_downloads, ?:product_file_descriptions.file_name, ?:product_file_ekeys.active, ?:product_file_ekeys.downloads, ?:product_file_ekeys.ekey, ?:product_file_ekeys.ttl FROM ?:product_files LEFT JOIN ?:product_file_descriptions ON ?:product_file_descriptions.file_id = ?:product_files.file_id AND ?:product_file_descriptions.lang_code = ?s LEFT JOIN ?:product_file_ekeys ON ?:product_file_ekeys.file_id = ?:product_files.file_id AND ?:product_file_ekeys.order_id = ?i WHERE ?:product_files.product_id = ?i", $lang_code, $order_id, $v['product_id']); } // Get shipments information if (Registry::get('settings.General.use_shipments') == 'Y') { if (isset($shipped_products[$k])) { $order['items'][$k]['shipped_amount'] = $shipped_products[$k]; $order['items'][$k]['shipment_amount'] = $v['amount'] - $shipped_products[$k]; } else { $order['items'][$k]['shipped_amount'] = 0; $order['items'][$k]['shipment_amount'] = $v['amount']; } if ($order['items'][$k]['shipped_amount'] < $order['items'][$k]['amount']) { $order['need_shipment'] = true; } } // Check if the order needs the shipping method if (!($v['extra']['is_edp'] == 'Y' && (!isset($v['extra']['edp_shipping']) || $v['extra']['edp_shipping'] != 'Y'))) { $order['need_shipping'] = true; } } if (fn_check_suppliers_functionality()) { $order['companies'] = fn_get_products_companies($order['items']); $order['have_suppliers'] = fn_check_companies_have_suppliers($order['companies']); } // Unserialize and collect taxes information if (!empty($additional_data['T'])) { $order['taxes'] = unserialize($additional_data['T']); if (is_array($order['taxes'])) { foreach ($order['taxes'] as $tax_id => $tax_data) { foreach ($tax_data['applies'] as $_id => $value) { if (strpos($_id, 'P_') !== false && isset($deps[$_id])) { $order['items'][$deps[$_id]]['tax_value'] += $value; if ($tax_data['price_includes_tax'] != 'Y') { $order['items'][$deps[$_id]]['subtotal'] += $value; $order['items'][$deps[$_id]]['display_subtotal'] += Registry::get('settings.Appearance.cart_prices_w_taxes') == 'Y' ? $value : 0; $order['tax_subtotal'] += $value; } } if (strpos($_id, 'S_') !== false && Registry::get('settings.Appearance.cart_prices_w_taxes') == 'Y') { if ($tax_data['price_includes_tax'] != 'Y') { $order['display_shipping_cost'] += $value; } } } } } else { $order['taxes'] = array(); } } if (!empty($additional_data['C'])) { $order['coupons'] = unserialize($additional_data['C']); } if (!empty($additional_data['R'])) { $order['secondary_currency'] = unserialize($additional_data['R']); } // Recalculate subtotal $order['subtotal'] = $order['display_subtotal'] = 0; foreach ($order['items'] as $v) { $order['subtotal'] += $v['subtotal']; $order['display_per_subtotal'] += $v['display_per_subtotal']; $order['display_subtotal'] += $v['display_subtotal']; } // Unserialize and collect payment information if (!empty($additional_data['P'])) { $order['payment_info'] = unserialize(fn_decrypt_text($additional_data['P'])); } if (empty($order['payment_info']) || !is_array($order['payment_info'])) { $order['payment_info'] = array(); } // Get shipping information if (!empty($additional_data['L'])) { $order['shipping'] = unserialize($additional_data['L']); } $order['doc_ids'] = db_get_hash_single_array("SELECT type, doc_id FROM ?:order_docs WHERE order_id = ?i", array('type', 'doc_id'), $order_id); } fn_set_hook('get_order_info', $order, $additional_data); //echo $_SERVER['REMOTE_ADDR']; if ($_SERVER['REMOTE_ADDR'] == "188.123.241.2") { // echo ; } $order['subtotal_discount'] = $order['subtotal_discount'] == "0.00" ? $order['discount'] : $order['subtotal_discount']; $metro = db_get_field("SELECT description FROM cscart_profile_field_descriptions WHERE object_type = 'V' AND object_id = ?i", $order['fields'][44]); //$firma = db_get_field("SELECT description FROM cscart_profile_field_descriptions WHERE object_type = 'V' AND object_id = ?i", $order['fields'][65]); $q = "SELECT value FROM cscart_profile_fields_data WHERE object_id =" . $order_id . " AND field_id = 65"; $vals = db_get_array($q); //var_dump($vals); //$firma = db_get_field("SELECT value FROM cscart_profile_fields_data WHERE object_id = ?i", $order['fields'][65]); $order['metro'] = $metro; $order['firma'] = $vals[0]["value"]; return $order; } return false; }
function fn_get_coupons_promotions($coupon = false) { $params = array('coupons' => true, 'coupon_code' => $coupon, 'active' => true, 'zone' => 'cart', 'sort_by' => 'priority', 'sort_order' => 'asc'); list($promotions, $params) = fn_get_promotions($params); return $promotions; }