function fn_calculate_price($product_id, $product_options, $selected_options, $putted_fields, $default_params = false) { $fields = fn_get_fields($product_id); $formula = db_get_field('SELECT formula FROM ?:ppc_formula WHERE product_id = ?i', $product_id); if (!empty($fields)) { if ($default_params === true) { foreach ($fields as $k1 => $v1) { $putted_fields[$v1['name']] = $v1['default_value']; } } foreach ($fields as $k1 => $v1) { $formula = str_replace('[val_' . $v1['position'] . ']', '[' . $putted_fields[$v1['name']] . ']', $formula); if ($v1['additional'] > 0) { if ($default_params === true) { $formula = str_replace('[addval_' . $v1['position'] . ']', '[' . 0 . ']', $formula); } else { $formula = str_replace('[addval_' . $v1['position'] . ']', '[' . $putted_fields['add' . $v1['name']] . ']', $formula); } } } } //$productArrayOtionsVariants = fn_get_options_variants_by_option_variant_id($product_id, $selected_options); //$view->assign('product_array_otions_variants', $productArrayOtionsVariants); //var_dump($productArrayOtionsVariants); if (!empty($selected_options)) { foreach ($selected_options as $k1 => $v1) { foreach ($product_options as $option) { if ($option['option_id'] == $k1) { if (!empty($option['variants'])) { foreach ($option['variants'] as $variant) { if ($variant['variant_id'] == $v1) { $var = !empty($variant['modifier']) ? $variant['modifier'] : 0; if ($_POST['variant_modifier_value']) { $var = $_POST['variant_modifier_value']; } break; } } } break; } } if (empty($var)) { $var = '0'; } $formula = str_replace('[opt_' . $k1 . ']', '[' . $var . ']', $formula); unset($var); } } // fn_get_product_option_data($option_id, $product_id, $lang_code = DESCR_SL) if (!empty($selected_options)) { foreach ($selected_options as $k1 => $v1) { foreach ($product_options as $option) { if ($option['option_id'] == $k1) { if (!empty($option['variants'])) { foreach ($option['variants'] as $variant) { if ($variant['variant_id'] == $v1) { $var = !empty($variant['weight_modifier']) ? $variant['weight_modifier'] : 0; break; } } } break; } } if (empty($var)) { $var = '0'; } $formula = str_replace('[optw_' . $k1 . ']', '[' . $var . ']', $formula); unset($var); } } $auth = $_SESSION['auth']; $def_price = fn_get_product_price($product_id, 1, $auth); $product = fn_get_product_data($product_id, $auth, CART_LANGUAGE, true, true, false, false, false); $def_weight = db_get_field('SELECT weight FROM ?:products WHERE product_id = ?i', $product_id); // fn_promotion_apply('catalog', $product, $auth); // if (!empty($product['discount'])) { // $def_price -= $product['discount']; // if ($def_price < 0) { // $def_price = 0; // } // } $formula = str_replace('[price]', '[' . $def_price . ']', $formula); $formula = str_replace('[weight]', '[' . floatval($def_weight) . ']', $formula); return $formula; }
public function index($id = 0, $params = array()) { $lang_code = $this->safeGet($params, 'lang_code', DEFAULT_LANGUAGE); if ($this->getParentName() == 'categories') { $parent_category = $this->getParentData(); $params['cid'] = $parent_category['category_id']; } if (!empty($id)) { $data = fn_get_product_data($id, $this->auth, $lang_code, '', true, true, true, false, false, false, false); if (empty($data)) { $status = Response::STATUS_NOT_FOUND; } else { $status = Response::STATUS_OK; } } else { $items_per_page = $this->safeGet($params, 'items_per_page', Registry::get('settings.Appearance.admin_products_per_page')); $params['extend'][] = 'categories'; list($products, $search) = fn_get_products($params, $items_per_page, $lang_code); $params['get_options'] = $this->safeGet($params, 'get_options', false); $params['get_features'] = $this->safeGet($params, 'get_features', true); $params['get_detailed'] = $this->safeGet($params, 'get_detailed', true); $params['get_icon'] = $this->safeGet($params, 'get_icon', true); $params['get_additional'] = $this->safeGet($params, 'get_additional', true); $params['detailed_params'] = $this->safeGet($params, 'detailed_params', false); $params['features_display_on'] = 'A'; fn_gather_additional_products_data($products, $params); $data = array('products' => array_values($products), 'params' => $search); $status = Response::STATUS_OK; } return array('status' => $status, 'data' => $data); }
function ls_get_fav_data() { //wishlist products footer carousel $_SESSION['wishlist'] = isset($_SESSION['wishlist']) ? $_SESSION['wishlist'] : array(); $wishlist =& $_SESSION['wishlist']; $_SESSION['continue_url'] = fn_ls_get_base_url(); $auth =& $_SESSION['auth']; //view products $products_footer = !empty($wishlist['products']) ? $wishlist['products'] : array(); $extra_products = array(); $wishlist_is_empty = fn_cart_is_empty($wishlist); if (!empty($products_footer)) { foreach ($products_footer as $k => $v) { $_options = array(); $extra = $v['extra']; if (!empty($v['product_options'])) { $_options = $v['product_options']; } $products_footer[$k] = fn_get_product_data($v['product_id'], $auth, CART_LANGUAGE, '', true, true, true, false, false, true, false, true); if (empty($products_footer[$k])) { unset($products_footer[$k], $wishlist['products'][$k]); continue; } $products_footer[$k]['extra'] = empty($products_footer[$k]['extra']) ? array() : $products_footer[$k]['extra']; $products_footer[$k]['extra'] = array_merge($products_footer[$k]['extra'], $extra); if (isset($products_footer[$k]['extra']['product_options']) || $_options) { $products_footer[$k]['selected_options'] = empty($products_footer[$k]['extra']['product_options']) ? $_options : $products_footer[$k]['extra']['product_options']; } if (!empty($products_footer[$k]['selected_options'])) { $options = fn_get_selected_product_options($v['product_id'], $v['product_options'], CART_LANGUAGE); foreach ($products_footer[$k]['selected_options'] as $option_id => $variant_id) { foreach ($options as $option) { if ($option['option_id'] == $option_id && !in_array($option['option_type'], array('I', 'T', 'F')) && empty($variant_id)) { $products_footer[$k]['changed_option'] = $option_id; break 2; } } } } $products_footer[$k]['display_subtotal'] = $products_footer[$k]['price'] * $v['amount']; $products_footer[$k]['display_amount'] = $v['amount']; $products_footer[$k]['cart_id'] = $k; if (!empty($products_footer[$k]['extra']['parent'])) { $extra_products[$k] = $products_footer[$k]; unset($products_footer[$k]); continue; } } } fn_gather_additional_products_data($products_footer, array('get_icon' => true, 'get_detailed' => true, 'get_options' => true, 'get_discounts' => true)); return $products_footer; }
function fn_exim_google_export_format_price($product_price, $product_id = 0) { static $auth; if (empty($auth)) { $auth = fn_fill_auth(); } $product = fn_get_product_data($product_id, $auth, CART_LANGUAGE, false, false, false, false, false, false, false); fn_promotion_apply('catalog', $product, $auth); $_discount = 0; if (!empty($product['discount'])) { $_discount = $product['discount']; } return fn_format_price($product_price - $_discount, CART_PRIMARY_CURRENCY, null, false); }
$_SESSION['wishlist'] = isset($_SESSION['wishlist']) ? $_SESSION['wishlist'] : array(); $wishlist =& $_SESSION['wishlist']; $_SESSION['continue_url'] = isset($_SESSION['continue_url']) ? $_SESSION['continue_url'] : ''; $auth =& $_SESSION['auth']; //view products $products_footer = !empty($wishlist['products']) ? $wishlist['products'] : array(); $extra_products = array(); $wishlist_is_empty = fn_cart_is_empty($wishlist); if (!empty($products_footer)) { foreach ($products_footer as $k => $v) { $_options = array(); $extra = $v['extra']; if (!empty($v['product_options'])) { $_options = $v['product_options']; } $products_footer[$k] = fn_get_product_data($v['product_id'], $auth, CART_LANGUAGE, '', true, true, true, false, false, true, false, true); if (empty($products_footer[$k])) { unset($products_footer[$k], $wishlist['products'][$k]); continue; } $products_footer[$k]['extra'] = empty($products_footer[$k]['extra']) ? array() : $products_footer[$k]['extra']; $products_footer[$k]['extra'] = array_merge($products_footer[$k]['extra'], $extra); if (isset($products_footer[$k]['extra']['product_options']) || $_options) { $products_footer[$k]['selected_options'] = empty($products_footer[$k]['extra']['product_options']) ? $_options : $products_footer[$k]['extra']['product_options']; } if (!empty($products_footer[$k]['selected_options'])) { $options = fn_get_selected_product_options($v['product_id'], $v['product_options'], CART_LANGUAGE); foreach ($products_footer[$k]['selected_options'] as $option_id => $variant_id) { foreach ($options as $option) { if ($option['option_id'] == $option_id && !in_array($option['option_type'], array('I', 'T', 'F')) && empty($variant_id)) { $products_footer[$k]['changed_option'] = $option_id;
function fn_twg_api_get_session_cart(&$cart, $lang_code = CART_LANGUAGE) { $data = array('amount' => 0, 'subtotal' => 0); $auth = $_SESSION['auth']; if (empty($cart)) { return $data; } $payment_methods = fn_twg_get_payment_methods(); if (isset($payment_methods['payment'])) { $payment_methods = $payment_methods['payment']; } if (false != ($first_method = reset($payment_methods)) && empty($cart['payment_id']) && isset($cart['total']) && floatval($cart['total']) != 0) { $cart['payment_id'] = $first_method['payment_id']; } if (isset($cart['total']) && floatval($cart['total']) == 0) { $cart['payment_id'] = 0; } // fetch cart data $cart_data = array_merge($data, Api::getAsApiObject('cart', $cart, array(), array('lang_code' => $lang_code))); if (!empty($cart_data['taxes'])) { $cart_data['taxes'] = Api::getAsList('taxes', $cart_data['taxes']); } if (!empty($cart_data['products'])) { $cart_data['products'] = array_reverse($cart_data['products']); } if (!empty($cart_data['payment_surcharge'])) { $cart_data['total'] += $cart_data['payment_surcharge']; } else { $cart_data['payment_surcharge'] = 0; } // ================ Payment buttons ======================================== $payment_buttons = array(); $checkout_processors = array('amazon_checkout.php', 'paypal_express.php', 'google_checkout.php'); $included_files = get_included_files(); $is_payments_included = false; foreach ($checkout_processors as $checkout_processor) { if (in_array(Registry::get('config.dir.payments') . $checkout_processor, $included_files)) { $is_payments_included = true; break; } } if ($is_payments_included) { // Get from templater $view = fn_twg_get_view_object(); $smarty_vars = array('checkout_add_buttons', 'checkout_buttons'); foreach ($smarty_vars as $smarty_var) { $buttons = $view->getTemplateVars($smarty_var); if ($buttons !== null) { $payment_buttons = $buttons; break; } } } else { // Get payments fiels if (!empty($cart['products'])) { foreach ($cart['products'] as $product_key => $product) { if (!isset($cart['products'][$product_key]['product'])) { $product_data = fn_get_product_data($product['product_id'], $auth); $cart['products'][$product_key]['product'] = $product_data['product']; $cart['products'][$product_key]['short_description'] = $product_data['short_description']; } } $mode = Registry::get('runtime.mode'); Registry::set('runtime.mode', 'cart'); # for the paypal express checkout $payment_buttons = fn_get_checkout_payment_buttons($cart, $cart['products'], $auth); Registry::set('runtime.mode', $mode); } } $cart_data['payment_buttons'] = fn_twg_filter_payment_buttons($payment_buttons); // ================ /Payment buttons ======================================= $cart_data['empty_payments'] = empty($payment_methods) ? 'Y' : 'N'; $cart_data['coupons'] = empty($cart['coupons']) ? array() : array_keys($cart['coupons']); $cart_data['use_gift_certificates'] = array(); $cart_data['gift_certificates_total'] = 0; if (isset($cart['use_gift_certificates'])) { foreach ($cart['use_gift_certificates'] as $code => $cert) { $cart_data['use_gift_certificates'][] = array('code' => $code, 'cost' => $cert['cost']); $cart_data['gift_certificates_total'] += $cert['cost']; } } foreach ($cart_data['products'] as &$product) { if (!empty($product['extra']['points_info']['reward']) && !is_array($product['extra']['points_info']['reward'])) { $product['extra']['points_info']['reward'] = array('amount' => $product['extra']['points_info']['reward']); } if (isset($product['extra']['points_info']) && Registry::get('addons.reward_points.status') != 'A') { unset($product['extra']['points_info']); } } if (!empty($cart['points_info'])) { $cart_data['points_info'] = $cart['points_info']; } return $cart_data; }
if (!empty($_REQUEST['banner_id']) && !isset($banner_product_ids[$_REQUEST['banner_id']])) { $banner_product_ids = array($_REQUEST['banner_id'] => array()); } $banner_data = fn_get_aff_banner_data($_REQUEST['banner_id'], CART_LANGUAGE, true); $banner_data['product_ids'] = implode('-', $banner_product_ids[$_REQUEST['banner_id']]); $banner_data['example'] = fn_get_aff_banner_html('js', $banner_data); $banner_data['code'] = fn_get_aff_banner_html('js', $banner_data, '', $auth['user_id']); $banner_data['url'] = fn_get_aff_banner_url($banner_data, $auth['user_id']); $view->assign('banner', $banner_data); // [Breadcrumbs] fn_add_breadcrumb(fn_get_lang_var('product_banners'), "banners_manager.manage?banner_type=P"); fn_add_breadcrumb($banner_data['title']); // [/Breadcrumbs] $linked_products = array(); foreach ($banner_product_ids[$_REQUEST['banner_id']] as $prod_id) { $linked_products[$prod_id] = fn_get_product_data($prod_id, $auth); $linked_products[$prod_id]['url'] = "{$banner_data['url']}&product_id={$prod_id}"; } $view->assign('linked_products', $linked_products); $view->assign('banner_id', $banner_data['banner_id']); } else { // [Page sections] if ($_REQUEST['banner_type'] != 'P') { foreach (array('groups' => 'product_groups', 'categories' => 'categories', 'products' => 'products', 'url' => 'url') as $k => $v) { Registry::set('navigation.tabs.' . $k, array('title' => fn_get_lang_var($v), 'href' => "banners_manager.manage?banner_type={$_REQUEST['banner_type']}&selected_section={$k}")); } } // [/Page sections] $banners = array(); $selected_section = empty($_REQUEST['selected_section']) ? $_REQUEST['banner_type'] == 'P' ? 'url' : 'groups' : $_REQUEST['selected_section']; if ($selected_section == 'groups') {
unset($cart_products[$cart_id]); $cart_products[$product['object_id']] = $product; } } } $_cart = $_SESSION['cart']; if (AREA == 'A') { $_auth = $_SESSION['customer_auth']; if (empty($_auth)) { $_auth = fn_fill_auth(array(), array(), false, 'C'); } } foreach ($cart_products as $cart_id => $item) { if (isset($_cart['products'][$cart_id])) { $amount = isset($item['amount']) ? $item['amount'] : 1; $product_data = fn_get_product_data($item['product_id'], $auth, CART_LANGUAGE, '', false, false, false, false, false, false, false); if ($product_data['options_type'] == 'S' && isset($item['product_options']) && isset($_REQUEST['changed_option'][$cart_id])) { $item['product_options'] = fn_fill_sequential_options($item, $_REQUEST['changed_option'][$cart_id]); unset($_REQUEST['changed_option']); } $product_options = isset($item['product_options']) ? $item['product_options'] : array(); $amount = fn_check_amount_in_stock($item['product_id'], $amount, $product_options, $cart_id, $_cart['products'][$cart_id]['is_edp'], 0, $_cart); if ($amount === false) { unset($_cart['products'][$cart_id]); continue; } $_cart['products'][$cart_id]['amount'] = $amount; $_cart['products'][$cart_id]['product_options'] = isset($item['product_options']) ? $item['product_options'] : array(); if (!empty($_cart['products'][$cart_id]['extra']['saved_options_key'])) { $_cart['saved_product_options'][$_cart['products'][$cart_id]['extra']['saved_options_key']] = $_cart['products'][$cart_id]['product_options']; }
/** * Add gift certificate to wishlist * * @param array $wishlist wishlist data storage * @param array $gift_cert_data array with data for the certificate to add * @return array array with gift certificate ID and data if addition is successful and empty array otherwise */ function fn_add_gift_certificate_to_wishlist(&$wishlist, $gift_cert_data) { if (!empty($gift_cert_data) && is_array($gift_cert_data)) { fn_correct_gift_certificate($gift_cert_data); // Generate wishlist id $gift_cert_wishlist_id = fn_generate_gift_certificate_cart_id($gift_cert_data); $wishlist['gift_certificates'][$gift_cert_wishlist_id] = $gift_cert_data; $gift_cert_data['display_subtotal'] = $gift_cert_data['amount']; if (!empty($gift_cert_data['products'])) { $product_data = array(); foreach ($gift_cert_data['products'] as $w_id => $_data) { if (empty($_data['amount'])) { unset($gift_cert_data['products'][$w_id]); continue; } if (empty($_data['product_options'])) { $_data['product_options'] = fn_get_default_product_options($_data['product_id']); } $wishlist_id = fn_generate_cart_id($_data['product_id'], array('product_options' => $_data['product_options'], 'parent' => array('certificate' => $gift_cert_wishlist_id)), true); $product_data[$wishlist_id] = $_data; $wishlist['products'][$wishlist_id] = array('product_id' => $_data['product_id'], 'product_options' => $_data['product_options'], 'amount' => $_data['amount'], 'extra' => array('parent' => array('certificate' => $gift_cert_wishlist_id))); $product = fn_get_product_data($_data['product_id'], $_SESSION['auth']); $gift_cert_data['display_subtotal'] += $_data['amount'] * $product['price']; } $gift_cert_data['products'] = $wishlist['gift_certificates'][$gift_cert_wishlist_id]['products'] = $product_data; } return array($gift_cert_wishlist_id, $gift_cert_data); } else { return array(); } }
if ($mode == 'get_products') { $_REQUEST['type'] = empty($_REQUEST['type']) ? 'extended' : $_REQUEST['type']; list($products) = fn_get_products($_REQUEST, Registry::get('settings.Appearance.products_per_page')); if (!empty($products)) { foreach ($products as $k => $v) { fn_gather_additional_product_data($products[$k], true); } } $xml .= fn_array_to_xml($products, 'products'); } // // View product details // if ($mode == 'get_product') { $_REQUEST['product_id'] = empty($_REQUEST['product_id']) ? 0 : $_REQUEST['product_id']; $product = fn_get_product_data($_REQUEST['product_id'], $auth, CART_LANGUAGE); if (!empty($product)) { if (!empty($_REQUEST['combination'])) { $product['combination'] = $combination; } fn_gather_additional_product_data($product, true, true); $xml .= fn_array_to_xml($product, 'product_data'); } } if ($mode == 'get_categories') { $_REQUEST['category_id'] = empty($_REQUEST['category_id']) ? 0 : $_REQUEST['category_id']; $params = array('category_id' => $_REQUEST['category_id'], 'visible' => false, 'plain' => !empty($_REQUEST['format']) && $_REQUEST['format'] == 'plain' ? true : false); list($categories, ) = fn_get_categories($params, CART_LANGUAGE); $xml .= fn_array_to_xml($categories, 'categories'); } if ($mode == 'get_category') {
function fn_add_product_to_cart_old($product_data, &$cart, &$auth, $update = false) { $ids = array(); if (!empty($product_data) && is_array($product_data)) { if (!defined('GET_OPTIONS')) { list($product_data, $cart) = fn_add_product_options_files($product_data, $cart, $auth, $update); } fn_set_hook('pre_add_to_cart', $product_data, $cart, $auth, $update); //var_dump($product_data);die(); foreach ($product_data as $key => $data) { if (empty($key)) { continue; } if (empty($data['amount'])) { continue; } $data['stored_price'] = !empty($data['stored_price']) && AREA != 'C' ? $data['stored_price'] : 'N'; if (empty($data['extra'])) { $data['extra'] = array(); } $product_id = !empty($data['product_id']) ? intval($data['product_id']) : intval($key); if (!fn_check_add_product_to_cart($cart, $data, $product_id)) { continue; } // Check if product options exist if (!isset($data['product_options'])) { $data['product_options'] = fn_get_default_product_options($product_id); } // Generate cart id $data['extra']['product_options'] = $data['product_options']; $_id = fn_generate_cart_id($product_id, $data['extra'], false); if (isset($ids[$_id]) && $key == $_id) { continue; } if (isset($data['extra']['exclude_from_calculate']) && $data['extra']['exclude_from_calculate']) { if (!empty($cart['products'][$key]) && !empty($cart['products'][$key]['extra']['aoc'])) { $cart['saved_product_options'][$cart['products'][$key]['extra']['saved_options_key']] = $data['product_options']; } if (isset($cart['deleted_exclude_products'][$data['extra']['exclude_from_calculate']][$_id])) { continue; } } $amount = fn_normalize_amount(@$data['amount']); if (!isset($data['extra']['exclude_from_calculate']) || isset($data['extra']['exclude_from_calculate']) && !$data['extra']['exclude_from_calculate']) { if ($data['stored_price'] != 'Y') { $allow_add = true; // Check if the product price with options modifiers equals to zero $price = fn_get_product_price($product_id, $amount, $auth); $zero_price_action = db_get_field("SELECT zero_price_action FROM ?:products WHERE product_id = ?i", $product_id); if (!floatval($price) && $zero_price_action == 'A') { if (isset($cart['products'][$key]['custom_user_price'])) { $price = $cart['products'][$key]['custom_user_price']; } else { $custom_user_price = empty($data['price']) ? 0 : $data['price']; } } if ($data['extra']['price_calc']['total_price_calc']) { $productTest = fn_get_product_data($product_id, $auth, CART_LANGUAGE, '', true, true, true, true, fn_is_preview_action($auth, $_REQUEST)); $productTest['extra']['product_options'] = $data['extra']['product_options']; fn_gather_additional_product_data($productTest, true, true); $price = $productTest['price']; } else { $price = fn_apply_options_modifiers($data['product_options'], $price, 'P', array(), array('product_data' => $data)); } if (!floatval($price)) { $data['price'] = isset($data['price']) ? fn_parse_price($data['price']) : 0; if (($zero_price_action == 'R' || $zero_price_action == 'A' && floatval($data['price']) < 0) && AREA == 'C') { if ($zero_price_action == 'A') { fn_set_notification('E', __('error'), __('incorrect_price_warning')); } $allow_add = false; } // $price = empty($data['price']) ? 0 : $data['price']; } /** * Recalculates price and checks if product can be added with the current price * * @param array $data Adding product data * @param float $price Calculated product price * @param boolean $allow_add Flag that determines if product can be added to cart */ fn_set_hook('add_product_to_cart_check_price', $data, $price, $allow_add); if (!$allow_add) { continue; } } else { if (!$price) { $price = fn_get_product_price($product_id, $amount, $auth); } $price = empty($data['price']) ? 0 : $data['price']; } } else { $price = 0; } //var_dump($price);echo"<br/><br/>"; $_data = db_get_row('SELECT is_edp, options_type, tracking, unlimited_download FROM ?:products WHERE product_id = ?i', $product_id); if (isset($_data['is_edp'])) { $data['is_edp'] = $_data['is_edp']; } elseif (!isset($data['is_edp'])) { $data['is_edp'] = 0; } if (isset($_data['options_type'])) { $data['options_type'] = $_data['options_type']; } if (isset($_data['tracking'])) { $data['tracking'] = $_data['tracking']; } if (isset($_data['unlimited_download'])) { $data['extra']['unlimited_download'] = $_data['unlimited_download']; } // Check the sequential options if (!empty($data['tracking']) && $data['tracking'] == 'O' && $data['options_type'] == 'S') { $inventory_options = db_get_fields("SELECT a.option_id FROM ?:product_options as a LEFT JOIN ?:product_global_option_links as c ON c.option_id = a.option_id WHERE (a.product_id = ?i OR c.product_id = ?i) AND a.status = 'A' AND a.inventory = 'Y'", $product_id, $product_id); $sequential_completed = true; if (!empty($inventory_options)) { foreach ($inventory_options as $option_id) { if (!isset($data['product_options'][$option_id]) || empty($data['product_options'][$option_id])) { $sequential_completed = false; break; } } } if (!$sequential_completed) { fn_set_notification('E', __('error'), __('select_all_product_options')); // Even if customer tried to add the product from the catalog page, we will redirect he/she to the detailed product page to give an ability to complete a purchase $redirect_url = fn_url('products.view?product_id=' . $product_id . '&combination=' . fn_get_options_combination($data['product_options'])); $_REQUEST['redirect_url'] = $redirect_url; //FIXME: Very very very BAD style to use the global variables in the functions!!! return false; } } if (!isset($cart['products'][$_id])) { // If product doesn't exists in the cart $amount = empty($data['original_amount']) ? fn_check_amount_in_stock($product_id, $amount, $data['product_options'], $_id, $data['is_edp'], 0, $cart, $update == true ? $key : 0) : $data['original_amount']; if ($amount === false) { continue; } $cart['products'][$_id]['product_id'] = $product_id; $cart['products'][$_id]['product_code'] = fn_get_product_code($product_id, $data['product_options']); $cart['products'][$_id]['product'] = fn_get_product_name($product_id); // if (isset($data['extra']['exclude_from_calculate']) && !$data['extra']['exclude_from_calculate']) { // $cart['products'][$_id]['amount'] = 0; // }else $cart['products'][$_id]['amount'] = $amount; $cart['products'][$_id]['product_options'] = $data['product_options']; $cart['products'][$_id]['price'] = $price; // Collect product's options and variants name $ls_minicart_options = fn_ls_get_minicart_options($data['product_options']); $cart['products'][$_id]['ls_minicart_options'] = $ls_minicart_options; if (!empty($zero_price_action) && $zero_price_action == 'A') { if (isset($custom_user_price)) { $cart['products'][$_id]['custom_user_price'] = $custom_user_price; } elseif (isset($cart['products'][$key]['custom_user_price'])) { $cart['products'][$_id]['custom_user_price'] = $cart['products'][$key]['custom_user_price']; } } $cart['products'][$_id]['stored_price'] = $data['stored_price']; // add image for minicart $cart['products'][$_id]['main_pair'] = fn_get_cart_product_icon($product_id, $data); fn_define_original_amount($product_id, $_id, $cart['products'][$_id], $data); if ($update == true && $key != $_id) { fn_delete_cart_product($cart, $key, false); } } else { // If product is already exist in the cart $_initial_amount = empty($cart['products'][$_id]['original_amount']) ? $cart['products'][$_id]['amount'] : $cart['products'][$_id]['original_amount']; // If ID changed (options were changed), summ the total amount of old and new products if ($update == true && $key != $_id) { $amount += $_initial_amount; fn_delete_cart_product($cart, $key, false); } if ($data['extra']['price_calc']['total_price_calc']) { $productTest = fn_get_product_data($product_id, $auth, CART_LANGUAGE, '', true, true, true, true, fn_is_preview_action($auth, $_REQUEST)); $productTest['extra']['product_options'] = $data['extra']['product_options']; fn_gather_additional_product_data($productTest, true, true); $cart['products'][$_id]['price'] = $productTest['price']; } $cart['products'][$_id]['amount'] = fn_check_amount_in_stock($product_id, ($update == true ? 0 : $_initial_amount) + $amount, $data['product_options'], $_id, !empty($data['is_edp']) && $data['is_edp'] == 'Y' ? 'Y' : 'N', 0, $cart, $update == true ? $key : 0); } $cart['products'][$_id]['extra'] = empty($data['extra']) ? array() : $data['extra']; $cart['products'][$_id]['stored_discount'] = @$data['stored_discount']; if (defined('ORDER_MANAGEMENT')) { $cart['products'][$_id]['discount'] = @$data['discount']; } // Increase product popularity if (empty($_SESSION['products_popularity']['added'][$product_id])) { $_data = array('product_id' => $product_id, 'added' => 1, 'total' => POPULARITY_ADD_TO_CART); db_query("INSERT INTO ?:product_popularity ?e ON DUPLICATE KEY UPDATE added = added + 1, total = total + ?i", $_data, POPULARITY_ADD_TO_CART); $_SESSION['products_popularity']['added'][$product_id] = true; } $company_id = db_get_field("SELECT company_id FROM ?:products WHERE product_id = ?i", $product_id); $cart['products'][$_id]['company_id'] = $company_id; if (!empty($data['saved_object_id'])) { $cart['products'][$_id]['object_id'] = $data['saved_object_id']; } fn_set_hook('add_to_cart', $cart, $product_id, $_id); if ($data['extra']['price_calc']['total_price_calc']) { foreach ($cart['product_groups'] as $key_product_groups => $product_groups) { $cart['product_groups'][$key_product_groups]['products'][$_id]['price'] = $cart['products'][$_id]['price']; $cart['product_groups'][$key_product_groups]['products'][$_id]['extra']['price_calc']['total_price_calc'] = $cart['products'][$_id]['price']; } } //$ids[$_id] = $product_id; } /** * Change product data after adding product to cart * * @param array $product_data Product data * @param array $cart Cart data * @param array $auth Auth data * @param bool $update Flag the determains if cart data are updated */ fn_set_hook('post_add_to_cart', $product_data, $cart, $auth, $update); $cart['recalculate'] = true; if (!empty($cart['chosen_shipping'])) { $cart['calculate_shipping'] = true; unset($cart['product_groups']); } return $ids; } else { return false; } }
$recent_order_status_text = "order_declined"; } elseif ($recent_order_status == "F") { $recent_order_status_text = "order_failed"; } elseif ($recent_order_status == "I") { $recent_order_status_text = "order_canceled"; } elseif ($recent_order_status == "O") { $recent_order_status_text = "order_opened"; } elseif ($recent_order_status == "P") { $recent_order_status_text = "order_processed"; } else { $recent_order_status_text = "opened"; } $shortlist = db_get_array("SELECT * FROM ?:user_session_products WHERE user_id=?i AND type='W' ORDER BY timestamp DESC", $auth['user_id']); $shortlist_number = count($shortlist); $last_shortlist_product_info = unserialize($shortlist[0]['extra']); $product = fn_get_product_data($last_shortlist_product_info['product_id'], $auth, CART_LANGUAGE, '', true, true, true, true); $product['selected_options'] = $last_shortlist_product_info['product_options']; fn_gather_additional_product_data($product, true, true); $return_requests = db_get_array("SELECT * FROM ?:rma_returns WHERE user_id=?i ORDER BY timestamp DESC", $auth['user_id']); $return_requests_number = count($return_requests); $aviable_return_requests = array(); if (count($return_requests) > 0) { foreach ($return_requests as $return_request) { if (in_array($return_request['status'], array('O'))) { array_push($aviable_return_requests, $return_request); } } } $aviable_return_requests_number = count($aviable_return_requests); Registry::get('view')->assign('orders_number', $orders_number); Registry::get('view')->assign('recent_order_status', $recent_order_status_text);
function content_55dc81a6027c27_25441318($_smarty_tpl) { if (!is_callable('smarty_function_math')) { include '/var/www/html/market/app/lib/vendor/smarty/smarty/libs/plugins/function.math.php'; } if (!is_callable('smarty_block_hook')) { include '/var/www/html/market/app/functions/smarty_plugins/block.hook.php'; } fn_preload_lang_vars(array('delete', 'edit', 'remove')); if (fn_allowed_for("ULTIMATE") && $_smarty_tpl->tpl_vars['product_id']->value && $_smarty_tpl->tpl_vars['runtime']->value['company_id']) { ?> <?php $_smarty_tpl->tpl_vars["product_data"] = new Smarty_variable(fn_get_product_data($_smarty_tpl->tpl_vars['product_id']->value, $_SESSION['auth'], @constant('CART_LANGUAGE'), "?:products.company_id,?:product_descriptions.product", false, false, false, false, false, false, true), null, 0); ?> <?php if ($_smarty_tpl->tpl_vars['product_data']->value['company_id'] != $_smarty_tpl->tpl_vars['runtime']->value['company_id']) { ?> <?php $_smarty_tpl->tpl_vars["product"] = new Smarty_variable(($tmp = @$_smarty_tpl->tpl_vars['product_data']->value['product']) === null || $tmp === '' ? $_smarty_tpl->tpl_vars['product']->value : $tmp, null, 0); ?> <?php if ($_smarty_tpl->tpl_vars['owner_company_id']->value && $_smarty_tpl->tpl_vars['owner_company_id']->value != $_smarty_tpl->tpl_vars['runtime']->value['company_id']) { ?> <?php $_smarty_tpl->tpl_vars["show_only_name"] = new Smarty_variable(true, null, 0); ?> <?php } ?> <?php } } ?> <?php if ($_smarty_tpl->tpl_vars['type']->value == "options") { ?> <tr <?php if (!$_smarty_tpl->tpl_vars['clone']->value) { ?> id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['root_id']->value, ENT_QUOTES, 'UTF-8'); ?> _<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['delete_id']->value, ENT_QUOTES, 'UTF-8'); ?> " <?php } ?> class="cm-js-item<?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> cm-clone hidden<?php } ?> "> <?php if ($_smarty_tpl->tpl_vars['position_field']->value) { ?> <td><input type="text" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> [<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['delete_id']->value, ENT_QUOTES, 'UTF-8'); ?> ]" value="<?php echo smarty_function_math(array('equation' => "a*b", 'a' => $_smarty_tpl->tpl_vars['position']->value, 'b' => 10), $_smarty_tpl); ?> " size="3" class="input-text-short" <?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> disabled="disabled"<?php } ?> /></td><?php } ?> <td> <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value, ENT_QUOTES, 'UTF-8'); if ($_smarty_tpl->tpl_vars['show_only_name']->value) { echo $_smarty_tpl->getSubTemplate("views/companies/components/company_name.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('object' => $_smarty_tpl->tpl_vars['product_data']->value), 0); } ?> <?php if ($_smarty_tpl->tpl_vars['options']->value) { ?> <br> <small><?php echo $_smarty_tpl->tpl_vars['options']->value; ?> </small> <?php } ?> <?php if (is_array($_smarty_tpl->tpl_vars['options_array']->value)) { ?> <?php $_smarty_tpl->tpl_vars["option"] = new Smarty_Variable(); $_smarty_tpl->tpl_vars["option"]->_loop = false; $_smarty_tpl->tpl_vars["option_id"] = new Smarty_Variable(); $_from = $_smarty_tpl->tpl_vars['options_array']->value; if (!is_array($_from) && !is_object($_from)) { settype($_from, 'array'); } foreach ($_from as $_smarty_tpl->tpl_vars["option"]->key => $_smarty_tpl->tpl_vars["option"]->value) { $_smarty_tpl->tpl_vars["option"]->_loop = true; $_smarty_tpl->tpl_vars["option_id"]->value = $_smarty_tpl->tpl_vars["option"]->key; ?> <input type="hidden" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> [product_options][<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['option_id']->value, ENT_QUOTES, 'UTF-8'); ?> ]" value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['option']->value, ENT_QUOTES, 'UTF-8'); ?> "<?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> disabled="disabled"<?php } ?> /> <?php } ?> <?php } ?> <?php if ($_smarty_tpl->tpl_vars['product_id']->value) { ?> <input type="hidden" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> [product_id]" value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product_id']->value, ENT_QUOTES, 'UTF-8'); ?> "<?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> disabled="disabled"<?php } ?> /> <?php } ?> <?php if ($_smarty_tpl->tpl_vars['amount_input']->value == "hidden") { ?> <input type="hidden" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> [amount]" value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['amount']->value, ENT_QUOTES, 'UTF-8'); ?> "<?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> disabled="disabled"<?php } ?> /> <?php } ?> </td> <?php if ($_smarty_tpl->tpl_vars['amount_input']->value == "text") { ?> <td class="center"> <?php if ($_smarty_tpl->tpl_vars['show_only_name']->value) { ?> <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['amount']->value, ENT_QUOTES, 'UTF-8'); ?> <?php } else { ?> <input type="text" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> [amount]" value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['amount']->value, ENT_QUOTES, 'UTF-8'); ?> " size="3" class="input-micro"<?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> disabled="disabled"<?php } ?> /> <?php } ?> </td> <?php } ?> <?php $_smarty_tpl->smarty->_tag_stack[] = array('hook', array('name' => "product_picker:table_column_options")); $_block_repeat = true; echo smarty_block_hook(array('name' => "product_picker:table_column_options"), null, $_smarty_tpl, $_block_repeat); while ($_block_repeat) { ob_start(); ?> <?php $_block_content = ob_get_clean(); $_block_repeat = false; echo smarty_block_hook(array('name' => "product_picker:table_column_options"), $_block_content, $_smarty_tpl, $_block_repeat); } array_pop($_smarty_tpl->smarty->_tag_stack); ?> <td class="nowrap"> <?php if (!$_smarty_tpl->tpl_vars['hide_delete_button']->value && !$_smarty_tpl->tpl_vars['show_only_name']->value) { ?> <?php $_smarty_tpl->_capture_stack[0][] = array("tools_list", null, null); ob_start(); ?> <li><?php smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => __("delete"), 'onclick' => "Tygh." . "\$" . ".cePicker('delete_js_item', '" . (string) $_smarty_tpl->tpl_vars['root_id']->value . "', '" . (string) $_smarty_tpl->tpl_vars['delete_id']->value . "', 'p'); return false;")); ?> </li> <?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]); if (!empty($_capture_buffer)) { if (isset($_capture_assign)) { $_smarty_tpl->assign($_capture_assign, ob_get_contents()); } if (isset($_capture_append)) { $_smarty_tpl->append($_capture_append, ob_get_contents()); } Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean(); } else { $_smarty_tpl->capture_error(); } ?> <div class="hidden-tools"> <?php smarty_template_function_dropdown($_smarty_tpl, array('content' => Smarty::$_smarty_vars['capture']['tools_list'])); ?> </div> <?php } else { ?> <?php } ?> </td> </tr> <?php } elseif ($_smarty_tpl->tpl_vars['type']->value == "product") { ?> <tr <?php if (!$_smarty_tpl->tpl_vars['clone']->value) { ?> id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['root_id']->value, ENT_QUOTES, 'UTF-8'); ?> _<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['delete_id']->value, ENT_QUOTES, 'UTF-8'); ?> " <?php } ?> class="cm-js-item<?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> cm-clone hidden<?php } ?> "> <?php if ($_smarty_tpl->tpl_vars['position_field']->value) { ?> <td><input type="text" name="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['input_name']->value, ENT_QUOTES, 'UTF-8'); ?> [<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['delete_id']->value, ENT_QUOTES, 'UTF-8'); ?> ]" value="<?php echo smarty_function_math(array('equation' => "a*b", 'a' => $_smarty_tpl->tpl_vars['position']->value, 'b' => 10), $_smarty_tpl); ?> " size="3" class="input-text-short" <?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> disabled="disabled"<?php } ?> /></td><?php } ?> <td><?php if (!$_smarty_tpl->tpl_vars['show_only_name']->value) { ?> <a href="<?php echo htmlspecialchars(fn_url("products.update?product_id=" . (string) $_smarty_tpl->tpl_vars['delete_id']->value), ENT_QUOTES, 'UTF-8'); ?> "><?php echo $_smarty_tpl->tpl_vars['product']->value; ?> </a><?php } else { echo $_smarty_tpl->tpl_vars['product']->value; ?> <?php echo $_smarty_tpl->getSubTemplate("views/companies/components/company_name.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('object' => $_smarty_tpl->tpl_vars['product_data']->value), 0); } ?> </td> <td> </td> <td class="nowrap"><?php if (!$_smarty_tpl->tpl_vars['hide_delete_button']->value && !$_smarty_tpl->tpl_vars['show_only_name']->value) { ?> <?php $_smarty_tpl->_capture_stack[0][] = array("tools_list", null, null); ob_start(); ?> <li><?php smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => __("edit"), 'href' => "products.update?product_id=" . (string) $_smarty_tpl->tpl_vars['delete_id']->value)); ?> </li> <li><?php smarty_template_function_btn($_smarty_tpl, array('type' => "list", 'text' => __("remove"), 'onclick' => "Tygh." . "\$" . ".cePicker('delete_js_item', '" . (string) $_smarty_tpl->tpl_vars['root_id']->value . "', '" . (string) $_smarty_tpl->tpl_vars['delete_id']->value . "', 'p'); return false;")); ?> </li> <?php list($_capture_buffer, $_capture_assign, $_capture_append) = array_pop($_smarty_tpl->_capture_stack[0]); if (!empty($_capture_buffer)) { if (isset($_capture_assign)) { $_smarty_tpl->assign($_capture_assign, ob_get_contents()); } if (isset($_capture_append)) { $_smarty_tpl->append($_capture_append, ob_get_contents()); } Smarty::$_smarty_vars['capture'][$_capture_buffer] = ob_get_clean(); } else { $_smarty_tpl->capture_error(); } ?> <div class="hidden-tools"> <?php smarty_template_function_dropdown($_smarty_tpl, array('content' => Smarty::$_smarty_vars['capture']['tools_list'])); ?> </div> <?php } ?> </td> </tr> <?php } elseif ($_smarty_tpl->tpl_vars['type']->value == "single") { ?> <span <?php if (!$_smarty_tpl->tpl_vars['clone']->value) { ?> id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['holder']->value, ENT_QUOTES, 'UTF-8'); ?> _<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product_id']->value, ENT_QUOTES, 'UTF-8'); ?> " <?php } ?> class="cm-js-item <?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> cm-clone hidden<?php } ?> "> <?php if (!$_smarty_tpl->tpl_vars['first_item']->value && $_smarty_tpl->tpl_vars['single_line']->value) { ?> <span class="cm-comma<?php if ($_smarty_tpl->tpl_vars['clone']->value) { ?> hidden<?php } ?> ">, </span><?php } ?> <div class="input-append"> <input class="cm-picker-value-description <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['extra_class']->value, ENT_QUOTES, 'UTF-8'); ?> " type="text" value="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['product']->value, ENT_QUOTES, 'UTF-8'); ?> " <?php if ($_smarty_tpl->tpl_vars['display_input_id']->value) { ?> id="<?php echo htmlspecialchars($_smarty_tpl->tpl_vars['display_input_id']->value, ENT_QUOTES, 'UTF-8'); ?> "<?php } ?> size="10" name="product_name" readonly="readonly" <?php echo htmlspecialchars($_smarty_tpl->tpl_vars['extra']->value, ENT_QUOTES, 'UTF-8'); ?> id="appendedInputButton"> <?php $_smarty_tpl->tpl_vars["_but_text"] = new Smarty_variable("<i class='icon-plus'></i>", null, 0); ?> <?php $_smarty_tpl->tpl_vars["_but_role"] = new Smarty_variable("icon", null, 0); ?> <?php echo $_smarty_tpl->getSubTemplate("buttons/button.tpl", $_smarty_tpl->cache_id, $_smarty_tpl->compile_id, 0, null, array('but_id' => "opener_picker_" . (string) $_smarty_tpl->tpl_vars['data_id']->value, 'but_href' => fn_url("products.picker?display=radio&company_ids=" . (string) $_smarty_tpl->tpl_vars['company_ids']->value . "&picker_for=" . (string) $_smarty_tpl->tpl_vars['picker_for']->value . "&extra=" . (string) $_smarty_tpl->tpl_vars['extra_var']->value . "&checkbox_name=" . (string) $_smarty_tpl->tpl_vars['checkbox_name']->value . "&except_id=" . (string) $_smarty_tpl->tpl_vars['except_id']->value . "&data_id=" . (string) $_smarty_tpl->tpl_vars['data_id']->value . (string) $_smarty_tpl->tpl_vars['extra_url']->value), 'but_text' => $_smarty_tpl->tpl_vars['_but_text']->value, 'but_role' => $_smarty_tpl->tpl_vars['_but_role']->value, 'but_icon' => $_smarty_tpl->tpl_vars['_but_icon']->value, 'but_target_id' => "content_" . (string) $_smarty_tpl->tpl_vars['data_id']->value, 'but_meta' => (string) $_smarty_tpl->tpl_vars['but_meta']->value . " cm-dialog-opener add-on btn"), 0); ?> </div> </span> <?php } }
function fn_get_paginated_product_features($request, $auth, $product_data = array(), $lang_code = DESCR_SL) { $path = array(); if (!empty($request['over'])) { // get features for categories of selected products only $categories = db_get_fields("SELECT ?:categories.id_path FROM ?:products_categories LEFT JOIN ?:categories ON ?:categories.category_id = ?:products_categories.category_id WHERE product_id IN (?n)", $_SESSION['product_ids']); foreach ($categories as $category) { $path = array_merge($path, explode('/', $category)); } $path = array_unique($path); } if (empty($product_data) && !empty($request['product_id'])) { $product_data = fn_get_product_data($request['product_id'], $auth, $lang_code, '', false, false, false, false, false, false, false, false); } if (!empty($product_data['product_id'])) { $path = !empty($product_data['main_category']) ? explode('/', db_get_field("SELECT id_path FROM ?:categories WHERE category_id = ?i", $product_data['main_category'])) : ''; if (fn_allowed_for('ULTIMATE')) { if ($product_data['shared_product'] == 'Y') { //we should get features for all categories, not only main $path = !empty($product_data['category_ids']) ? explode('/', implode('/', db_get_fields("SELECT id_path FROM ?:categories WHERE category_id IN (?a)", $product_data['category_ids']))) : ''; } } } $_params = fn_array_merge($request, array('category_ids' => $path, 'product_company_id' => !empty($product_data['company_id']) ? $product_data['company_id'] : 0, 'statuses' => array('A', 'H'), 'variants' => true, 'plain' => false, 'display_on' => '', 'existent_only' => false, 'variants_selected_only' => false)); return fn_get_product_features($_params, PRODUCT_FEATURES_THRESHOLD, $lang_code); }
function fn_look_through_variants_prices($product_id, $options, $variants) { $product = fn_get_product_data($product_id, $_SESSION['auth'], CART_LANGUAGE, '', true, true, true, true, $auth['area'] == 'A' && !empty($_REQUEST['action']) && $_REQUEST['action'] == 'preview'); $product['product_options'] = fn_get_product_options(array($product_id), CART_LANGUAGE); $product = fn_apply_options_rules($product); //var_dump($product['product_options']); $position = 0; $hashes = array(); $combinations = fn_get_options_combinations($options, $variants); //var_dump($combinations); foreach ($combinations as $key => $combination) { $flagToUnsetArrayElement = 0; $productArrayOtionsVariants = fn_get_options_variants_by_option_variant_id($product_id, $combination); foreach ($combination as $optionId => $variantId) { if ($productArrayOtionsVariants[$optionId] && !in_array($variantId, $productArrayOtionsVariants[$optionId])) { $flagToUnsetArrayElement = 1; } } if ($flagToUnsetArrayElement == 1) { unset($combinations[$key]); } } //var_dump($combinations); if (!empty($combinations)) { foreach ($combinations as $combination) { $_data = array(); $_data['product_id'] = $product_id; $_data['combination_hash'] = fn_generate_cart_id($product_id, array('product_options' => $combination)); if (array_search($_data['combination_hash'], $hashes) === false) { $hashes[] = $_data['combination_hash']; $_data['combination'] = fn_get_options_combination($combination); $product['product_options'] = fn_get_selected_product_options($product['product_id'], $combination, CART_LANGUAGE); $product = fn_apply_options_rules($product); $_data['price'] = fn_calculate_price_of_a_product($product, $combination); $old_data = db_get_row("SELECT combination_hash, price " . "FROM ?:product_options_inventory_prices " . "WHERE product_id = ?i AND combination_hash = ?i AND temp = 1", $product_id, $_data['combination_hash']); /** * Changes data before update combination * * @param array $combination Array of combination data * @param array $data Combination data to update * @param int $product_id Product identifier * @param int $amount Default combination amount * @param array $options Array of options identifiers * @param array $variants Array of option variants identifiers arrays in order corresponding to $options parameter */ db_query("REPLACE INTO ?:product_options_inventory_prices ?e", $_data); $combinations[] = $combination; } echo str_repeat('. ', count($combination)); } } }
/** * Prepare and sends products data to update buyer info. * event - save_cart * * @return bool */ function fn_triggmine_save_cart($cart, $user_id, $type) { if (isset($cart['products'])) { $products = $cart['products']; $items = array(); foreach ($products as $product) { $item = array(); $ImageInfo = fn_get_cart_product_icon($product['product_id']); $item['CartItemId'] = $product['product_id']; $item['Title'] = $product['product']; $item['Count'] = $product['amount']; $item['Price'] = $product['price']; $product_data = fn_get_product_data($product['product_id'], $_SESSION['auth']); if (isset($product_data['meta_description'])) { $item['Description'] = $product_data['meta_description']; } if (isset($ImageInfo['detailed'])) { $ImageUrl = $ImageInfo['detailed']['http_image_path']; $item['ImageUrl'] = $ImageUrl; } //TODO add ThumbnailUrl /*if (isset($item['ThumbnailUrl'])) { $ImageThumbnailUrl = path to ThumbnailUrl; }*/ $items['Items'][] = $item; } $integrator = Triggmine_Integrator_CS_Cart::singleton(); $integrator->_onCartFullUpdate($items); return true; } else { return false; } }
function fn_get_element_condition($table_id, $element_hash, $for_calculate = false) { $auth =& $_SESSION['auth']; $element_id = db_get_field("SELECT element_id FROM ?:sales_reports_table_elements WHERE element_hash = ?s", $element_hash); $data = db_get_row("SELECT * FROM ?:sales_reports_elements WHERE element_id = ?i", $element_id); $cond = db_get_fields("SELECT ids FROM ?:sales_reports_table_element_conditions WHERE table_id = ?i AND element_hash = ?s", $table_id, $element_hash); foreach ($cond as $k => $v) { $data['conditions'][$v] = $v; if (!$for_calculate) { if ($data['code'] == 'product') { $data['conditions'][$v] = fn_get_product_data($v, $auth, CART_LANGUAGE, true, false, false); } if ($data['code'] == 'user') { $data['conditions'][$v] = fn_get_user_info($v, false); } if ($data['code'] == 'order') { $data['conditions'][$v] = db_get_row("SELECT * FROM ?:orders WHERE order_id = ?i", $v); } } } return $data = empty($data) ? false : $data; }
} if ($_SERVER['REQUEST_METHOD'] == 'POST') { if ($mode == 'options') { if (!empty($_REQUEST['product_data']) && !empty($_REQUEST['appearance']['wishlist'])) { $wishlist = $_SESSION['wishlist']; $product_data = $_REQUEST['product_data']; foreach ($product_data as $id => $product) { if (isset($wishlist['products'][$id])) { $wishlist['products'][$id] = array_merge($wishlist['products'][$id], $product); } } $products = !empty($wishlist['products']) ? $wishlist['products'] : array(); if (!empty($products)) { foreach ($products as $k => $v) { $extra = $v['extra']; $products[$k] = fn_get_product_data($v['product_id'], $auth); if (empty($products[$k])) { unset($products[$k], $wishlist['products'][$k]); continue; } $products[$k]['extra'] = empty($products[$k]['extra']) ? array() : $products[$k]['extra']; $products[$k]['extra'] = array_merge($products[$k]['extra'], $extra); if (isset($products[$k]['extra']['product_options'])) { $products[$k]['selected_options'] = $product_data[$k]['product_options']; } fn_gather_additional_product_data($products[$k], true); } } $view->assign('products', $products); $view->assign('wishlist', $wishlist); $view->display('addons/wishlist/views/wishlist/view.tpl');
protected function checkProductId($product_id) { $status = Response::STATUS_OK; $message = ''; if (!empty($product_id)) { $product_data = fn_get_product_data($product_id, $this->auth, DESCR_SL, '', false, false, false, false, false, false, false); if (empty($product_data)) { $status = Response::STATUS_FORBIDDEN; $message = __('access_denied'); } } else { $status = Response::STATUS_BAD_REQUEST; $message = __('api_required_field', array('[field]' => 'product_id')); } return array($status, $message); }
} // ---------------------- GET routines --------------------------------------- if ($mode == 'update') { $affiliate_plan = fn_get_affiliate_plan_data($_REQUEST['plan_id'], DESCR_SL); if (empty($affiliate_plan)) { return array(CONTROLLER_STATUS_NO_PAGE); } // [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] $linked_products = array(); foreach ($affiliate_plan['product_ids'] as $prod_id => $sale) { $linked_products[$prod_id] = fn_get_product_data($prod_id, $auth, DESCR_SL); $linked_products[$prod_id]['sale'] = $sale; } $view->assign('linked_products', $linked_products); $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];
list($cart_products) = fn_calculate_cart_content($_cart, $auth, 'S', true, 'F', false); if (!empty($_cart['points_info'])) { Registry::set("runtime.product_configurator.points_info.{$product_id}", $_cart['points_info']); } // Restore cart data $_SESSION['cart'] = $cart; if (!empty($_REQUEST['appearance'])) { foreach ($_REQUEST['appearance'] as $setting => $value) { $view->assign($setting, $value); } $view->assign('no_images', true); } $product = reset($cart_products); if (!empty($product['amount'])) { $product['selected_amount'] = $product['amount']; } $additional_data = fn_get_product_data($product['product_id'], $auth, CART_LANGUAGE, '', false, false, true, true); if (!empty($additional_data)) { $product = array_merge($additional_data, $product); } $product['configuration_mode'] = true; fn_gather_additional_product_data($product, true, false, true, false); // Clear all the user notifications $_SESSION['notifications'] = array(); $view->assign('product', $product); $view->display('views/products/view.tpl'); exit; } } } }
// Update option // } elseif ($mode == 'update') { $product_id = !empty($_REQUEST['product_id']) ? $_REQUEST['product_id'] : 0; $o_data = fn_get_product_option_data($_REQUEST['option_id'], $product_id); if (fn_allowed_for('ULTIMATE') && !empty($_REQUEST['product_id'])) { Registry::get('view')->assign('shared_product', fn_ult_is_shared_product($_REQUEST['product_id'])); Registry::get('view')->assign('product_company_id', db_get_field('SELECT company_id FROM ?:products WHERE product_id = ?i', $_REQUEST['product_id'])); } if (isset($_REQUEST['object'])) { Registry::get('view')->assign('object', $_REQUEST['object']); } Registry::get('view')->assign('option_data', $o_data); Registry::get('view')->assign('option_id', $_REQUEST['option_id']); } if (!fn_allowed_for('ULTIMATE:FREE')) { // // Product options exceptions // if ($mode == 'exceptions') { $exceptions = fn_get_product_exceptions($_REQUEST['product_id']); $product_options = fn_get_product_options($_REQUEST['product_id'], DESCR_SL, true); $product_data = fn_get_product_data($_REQUEST['product_id'], $auth, DESCR_SL, '', true, true, true, true); Registry::get('view')->assign('product_options', $product_options); Registry::get('view')->assign('exceptions', $exceptions); Registry::get('view')->assign('product_data', $product_data); } } if (!empty($_REQUEST['product_id'])) { Registry::get('view')->assign('product_id', $_REQUEST['product_id']); }
function fn_buy_together_calculate_cart_items(&$cart, &$cart_products, $auth) { if (empty($cart['products'])) { return true; } $is_valid = true; $check_amount = Registry::get('settings.General.inventory_tracking') == 'Y' && Registry::get('settings.General.allow_negative_amount') != 'Y' ? true : false; foreach ($cart['products'] as $key => $product) { if (!empty($product['extra']['buy_together'])) { $allowed = true; $_products = array(); $cart['products'][$key]['original_amount'] = $product['amount']; // Validate the combination $params['chain_id'] = $product['extra']['chain']['chain_id']; $params['status'] = 'A'; $params['full_info'] = true; $params['date'] = true; $params['simple'] = true; $chain = fn_buy_together_get_chains($params, $auth); if (empty($chain)) { $allowed = false; } $_product = fn_get_product_data($product['product_id'], $auth, CART_LANGUAGE, '', false, false, false, false); if (empty($_product) || $check_amount && $product['amount'] > $_product['amount']) { $allowed = false; } foreach ($cart['products'] as $k => $v) { if (!empty($v['extra']['parent']['buy_together']) && ($v['extra']['parent']['buy_together'] == $key || isset($product['extra']['buy_id']) && $product['extra']['buy_id'] == $v['extra']['parent']['buy_together'])) { $_products[] = $k; $cart['products'][$k]['original_amount'] = $v['amount']; if (isset($product['extra']['buy_id']) && $product['extra']['buy_id'] == $v['extra']['parent']['buy_together']) { $v['extra']['parent']['buy_together'] = $cart_products[$k]['extra']['parent']['buy_together'] = $cart['products'][$k]['extra']['parent']['buy_together'] = $key; } if ($allowed) { $_product = fn_get_product_data($v['product_id'], $auth, CART_LANGUAGE, '', false, false, false, false); if (empty($_product) || $check_amount && $v['amount'] > $_product['amount'] && !defined('ORDER_MANAGEMENT')) { fn_set_notification('E', fn_get_lang_var('notice'), str_replace(array('[product]', '[amount]'), array($_product['product'], $v['amount']), fn_get_lang_var('buy_together_product_was_removed'))); $allowed = false; } if (AREA != 'A' && MODE != 'place_order') { $chain_discount = empty($chain['products'][$v['extra']['chain']['hash']]['discount']) ? 0 : $chain['products'][$v['extra']['chain']['hash']]['discount']; $cart_products[$k]['price'] -= $chain_discount; $cart_products[$k]['base_price'] -= $chain_discount; $cart_products[$k]['price'] = $cart_products[$k]['price'] < 0 ? 0 : $cart_products[$k]['price']; $cart_products[$k]['base_price'] = $cart_products[$k]['base_price'] < 0 ? 0 : $cart_products[$k]['base_price']; $cart_products[$k]['original_price'] = $cart_products[$k]['subtotal'] = $cart_products[$k]['price']; } elseif (AREA != 'A' && MODE == 'place_order') { $cart_products[$k]['discount'] = 0; $cart_products[$k]['base_price'] = $cart_products[$k]['price'] - $cart_products[$k]['modifiers_price']; } } } if (AREA != 'A' && MODE == 'place_order') { $cart_products[$key]['base_price'] = $cart_products[$key]['price'] - $cart_products[$key]['modifiers_price']; } } if (AREA != 'A' && (!$allowed || count($_products) != count($product['extra']['buy_together']))) { $_products[] = $key; $cart['amount'] -= $product['amount']; foreach ($_products as $c_key) { unset($cart['products'][$c_key]); unset($cart_products[$c_key]); } $is_valid = false; } elseif (AREA != 'A' && MODE != 'place_order') { $cart_products[$key]['price'] -= empty($chain['discount']) ? 0 : $chain['discount']; if ($cart_products[$key]['price'] < 0) { $cart_products[$key]['price'] = 0; } $cart_products[$key]['base_price'] -= $chain['discount']; $cart_products[$key]['base_price'] = $cart_products[$key]['base_price'] < 0 ? 0 : $cart_products[$key]['base_price']; $cart_products[$key]['original_price'] = $cart_products[$key]['subtotal'] = $cart_products[$key]['price']; } elseif (AREA != 'A' && MODE == 'place_order') { $cart_products[$key]['discount'] = 0; } } } if (!$is_valid) { fn_set_notification('E', fn_get_lang_var('error'), fn_get_lang_var('buy_together_combination_cannot_be_added')); } return $is_valid; }
$test_email = $_REQUEST['test_email']; $remind = $_REQUEST['settings_data']; $remind['lang_code'] = DESCR_SL; if (fn_validate_email($test_email)) { $statuses = $remind['statuses']; $remind_orders = db_get_array("SELECT * FROM ?:orders WHERE status in (?a) AND lang_code=?s", $statuses, $remind['lang_code']); if (!empty($remind_orders)) { $remind_order = array_pop($remind_orders); $order_info = fn_get_order_info($remind_order['order_id']); $letter['body'] = $remind['body']; $letter['subject'] = $remind['subject']; $customer_name = $order_info['firstname'] . ' ' . $remind_order['lastname']; $company = db_get_field("SELECT company FROM ?:companies WHERE company_id=?i", $remind_order['company_id']); $products = array(); foreach ($order_info['products'] as $key => $product) { $product_data = fn_get_product_data($product['product_id'], $_SESSION['auth']); if (!empty($product_data['discussion_type']) && $product_data['discussion_type'] != 'D') { $products[$product['product_id']] = $product_data; } } if (!empty($products)) { Registry::get('view')->assign('products', $products); $products_block = Registry::get('view')->fetch('addons/orders_feedback/components/products.tpl'); } else { $products_block = ''; } $letter['body'] = str_replace("%" . __("products_block") . "%", $products_block, $letter['body']); $letter['body'] = str_replace("%" . __("feedback_customer_firstname") . "%", $order_info['firstname'], $letter['body']); $letter['subject'] = str_replace("%" . __("feedback_customer_firstname") . "%", $order_info['firstname'], $letter['subject']); $letter['body'] = str_replace("%" . __("feedback_customer_lastname") . "%", $order_info['lastname'], $letter['body']); $letter['subject'] = str_replace("%" . __("feedback_customer_lastname") . "%", $order_info['lastname'], $letter['subject']);
foreach ($_REQUEST['appearance'] as $setting => $value) { $view->assign($setting, $value); } } $view->assign('show_images', true); $view->assign('no_capture', true); if (!empty($_REQUEST['product_data'])) { // Product data unset($_REQUEST['product_data']['custom_files']); $product_data = $_REQUEST; list($product_id, $_data) = each($product_data['product_data']); $product_id = isset($_data['product_id']) ? $_data['product_id'] : $product_id; $selected_options = empty($_data['product_options']) ? array() : $_data['product_options']; unset($selected_options['AOC']); if (isset($product_data['additional_info']['info_type']) && $product_data['additional_info']['info_type'] == 'D') { $product = fn_get_product_data($product_id, $_auth, CART_LANGUAGE, '', true, true, true, true); } else { $params['type'] = 'extended'; $params['pid'] = $product_id; list($product) = fn_get_products($params); $product = reset($product); } if (empty($product)) { return array(CONTROLLER_STATUS_NO_PAGE); } $product['changed_option'] = isset($product_data['changed_option']) ? reset($product_data['changed_option']) : ''; $product['selected_options'] = $selected_options; if (!empty($_data['amount'])) { $product['selected_amount'] = $_data['amount']; } // Get specific settings
/** * Construct * @param int|array $product Product id or array of product data * ```php * array( * 'product_id' => int, * 'ebay_template_id' => int, * ... * ) * ``` * @param string|array $relations Default * - all relations load * array( * 'additional', * 'options', * 'external' * ); */ public function __construct($product, $relations = '*') { if (!is_array($product)) { $product_id = (int) $product; $auth = \Tygh::$app['session']['auth']; $product = fn_get_product_data($product_id, $auth, CART_LANGUAGE); if ($relations === '*' || in_array('additional', $relations)) { fn_gather_additional_product_data($product, true, true); } } if (!empty($product)) { $this->init($product); if ($relations === '*' || in_array('external', $relations)) { $this->loadExternalData(); } if ($relations === '*' || in_array('options', $relations)) { $this->loadOptions(); } } }
function fn_is_accessible_discussion($data, &$auth) { $access = false; if ($data['object_type'] == 'P') { //product $access = fn_get_product_data($data['object_id'], $auth, CART_LANGUAGE, $field_list = '?:products.product_id', false, false, false); } elseif ($data['object_type'] == 'C') { //category $access = fn_get_category_data($data['object_id'], '', $field_list = '?:categories.category_id', false); } elseif ($data['object_type'] == 'M') { //company $access = fn_get_company_data($data['object_id']); } elseif ($data['object_type'] == 'O') { //order if (!empty($auth['user_id'])) { $access = db_get_field("SELECT order_id FROM ?:orders WHERE order_id = ?i AND user_id = ?i", $data['object_id'], $auth['user_id']); } elseif (!empty($auth['order_ids'])) { $access = in_array($data['object_id'], $auth['order_ids']); } } elseif ($data['object_type'] == 'A') { // page $access = fn_get_page_data($data['object_id'], CART_LANGUAGE); } elseif ($data['object_type'] == 'E') { // testimonials $access = true; } fn_set_hook('is_accessible_discussion', $data, $auth, $access); return !empty($access); }
if (Registry::get('settings.General.show_out_of_stock_products') == 'N') { $join = " LEFT JOIN ?:product_options_inventory as inventory ON inventory.product_id = ?:products.product_id"; $where = " AND IF(?:products.tracking = 'O', inventory.amount > 0, ?:products.amount > 0)"; } foreach ($product_configurator_groups as $k => $v) { $class_ids = db_get_fields("SELECT class_id FROM ?:conf_classes WHERE group_id = ?i", $v['group_id']); $_products = db_get_array("SELECT ?:product_descriptions.product, ?:product_descriptions.product_id , MIN(?:product_prices.price) as price, ?:conf_class_products.class_id, ?:products.tax_ids, ?:products.amount FROM ?:conf_group_products LEFT JOIN ?:products ON ?:products.product_id = ?:conf_group_products.product_id LEFT JOIN ?:product_descriptions ON ?:product_descriptions.product_id = ?:conf_group_products.product_id AND ?:product_descriptions.lang_code = ?s LEFT JOIN ?:product_prices ON ?:product_prices.product_id = ?:product_descriptions.product_id AND ?:product_prices.lower_limit = '1' ?p LEFT JOIN ?:conf_class_products ON ?:conf_class_products.class_id IN (?n) AND ?:conf_class_products.product_id = ?:conf_group_products.product_id ?p WHERE ?:conf_group_products.group_id = ?i AND ?:products.status IN ('A', 'H') ?p GROUP BY ?:product_prices.product_id ORDER BY ?:product_descriptions.product", CART_LANGUAGE, $price_usergroup, $class_ids, $join, $v['group_id'], $where); if (empty($_products)) { unset($product_configurator_groups[$k]); continue; } $default_ids = explode(':', $v['default_product_ids']); $selected_ids = empty($selected_configuration[$v['group_id']]) ? $default_ids : (!is_array($selected_configuration[$v['group_id']]) ? array($selected_configuration[$v['group_id']]) : $selected_configuration[$v['group_id']]); foreach ($_products as $_k => $_v) { // Selected products $_v = array_merge($_v, fn_get_product_data($_v['product_id'], $auth, CART_LANGUAGE, '', true, true, true, true)); fn_gather_additional_product_data($_v, false, false, false, true, false); $_products[$_k] = $_v; if (in_array($_v['product_id'], $selected_ids)) { $_products[$_k]['selected'] = 'Y'; $c_price += $_products[$_k]['price']; } else { $_products[$_k]['selected'] = 'N'; } // Recommended products if (in_array($_v['product_id'], $default_ids)) { $_products[$_k]['recommended'] = 'Y'; } $_products[$_k]['compatible_classes'] = db_get_hash_array("SELECT ?:conf_compatible_classes.slave_class_id, ?:conf_classes.group_id FROM ?:conf_compatible_classes LEFT JOIN ?:conf_classes ON ?:conf_classes.class_id = ?:conf_compatible_classes.slave_class_id WHERE ?:conf_compatible_classes.master_class_id = ?i AND ?:conf_classes.status = 'A'", 'slave_class_id', $_v['class_id']); } $product_configurator_groups[$k]['products_count'] = count($_products);
function fn_product_configurator_buy_together_restricted_product($product_id, $auth, $is_restricted, $show_notification) { if ($is_restricted) { return true; } $product_data = Registry::get('view')->get_var('product_data'); if (!empty($product_data)) { if ($product_data['product_type'] == 'C') { $is_restricted = true; } } elseif (!empty($product_id)) { $product_data = fn_get_product_data($product_id, $auth, CART_LANGUAGE, '', true, true, true, true); if ($product_data['product_type'] == 'C') { $is_restricted = true; } } if ($is_restricted && $show_notification) { fn_set_notification('E', fn_get_lang_var('error'), str_replace('[product_name]', $product_data['product'], fn_get_lang_var('buy_together_is_not_compatible_with_configurator'))); } }
function fn_get_product_data_for_compare($product_ids, $action) { $auth =& $_SESSION['auth']; $comparison_data = array('product_features' => array(0 => array())); $tmp = array(); foreach ($product_ids as $product_id) { $product_data = fn_get_product_data($product_id, $auth, CART_LANGUAGE, '', false, true, false, false); fn_gather_additional_product_data($product_data, false, false, false, true, false); if (!empty($product_data['product_features'])) { foreach ($product_data['product_features'] as $k => $v) { if ($v['feature_type'] == 'G' && empty($v['subfeatures'])) { continue; } $_features = $v['feature_type'] == 'G' ? $v['subfeatures'] : array($k => $v); $group_id = $v['feature_type'] == 'G' ? $k : 0; $comparison_data['feature_groups'][$k] = $v['description']; foreach ($_features as $_k => $_v) { if (in_array($_k, $_SESSION['excluded_features'])) { if (empty($comparison_data['hidden_features'][$_k])) { $comparison_data['hidden_features'][$_k] = $_v['description']; } continue; } if (empty($comparison_data['product_features'][$group_id][$_k])) { $comparison_data['product_features'][$group_id][$_k] = $_v['description']; } } } } $comparison_data['products'][] = $product_data; unset($product_data); } if ($action != 'show_all' && !empty($comparison_data['product_features'])) { $value = ''; foreach ($comparison_data['product_features'] as $group_id => $v) { foreach ($v as $feature_id => $_v) { unset($value); $c = $action == 'similar_only' ? true : false; foreach ($comparison_data['products'] as $product) { $features = !empty($group_id) && isset($product['product_features'][$group_id]) ? $product['product_features'][$group_id]['subfeatures'] : $product['product_features']; if (empty($features[$feature_id])) { $c = !$c; break; } if (!isset($value)) { $value = fn_get_feature_selected_value($features[$feature_id]); continue; } elseif ($value != fn_get_feature_selected_value($features[$feature_id])) { $c = !$c; break; } } if ($c == false) { unset($comparison_data['product_features'][$group_id][$feature_id]); } } } } return $comparison_data; }