} } $suffix .= '.manage'; } if ($mode == 'test') { $shipping_data = $_REQUEST['shipping_data']; if (!empty($shipping_data['service_id']) && !empty($_REQUEST['shipping_id'])) { // Set package information (weight is only needed) $weight = floatval($shipping_data['test_weight']); $weight = !empty($weight) ? sprintf("%.2f", $weight) : '0.01'; $package_info = array('W' => $weight, 'C' => 100, 'I' => 1, 'packages' => array(array('products' => array(), 'amount' => 1, 'weight' => $weight, 'cost' => 100)), 'origination' => array('name' => Registry::get('settings.Company.company_name'), 'address' => Registry::get('settings.Company.company_address'), 'city' => Registry::get('settings.Company.company_city'), 'country' => Registry::get('settings.Company.company_country'), 'state' => Registry::get('settings.Company.company_state'), 'zipcode' => Registry::get('settings.Company.company_zipcode'), 'phone' => Registry::get('settings.Company.company_phone'), 'fax' => Registry::get('settings.Company.company_fax'))); // Set default location $location = $package_info['location'] = fn_get_customer_location(array('user_id' => 0), array()); $service_params = !empty($shipping_data['service_params']) ? $shipping_data['service_params'] : array(); $shipping = Shippings::getShippingForTest($_REQUEST['shipping_id'], $shipping_data['service_id'], $service_params, $package_info); $rates = Shippings::calculateRates(array($shipping)); Tygh::$app['view']->assign('data', $rates[0]); Tygh::$app['view']->assign('weight', $weight); Tygh::$app['view']->assign('service', db_get_field("SELECT description FROM ?:shipping_service_descriptions WHERE service_id = ?i AND lang_code = ?s", $shipping_data['service_id'], DESCR_SL)); } Tygh::$app['view']->display('views/shippings/components/test.tpl'); exit; } // // Delete shipping methods // //TODO make security check for company_id if ($mode == 'm_delete') { if (!empty($_REQUEST['shipping_ids'])) { foreach ($_REQUEST['shipping_ids'] as $id) { if (fn_check_company_id('shippings', 'shipping_id', $id)) {
function fn_sdek_calculate_cost_by_shipment($order_info, $shipping_info, $shipment_info, $rec_city_code) { $total = $weight = 0; $goods = array(); $length = $width = $height = 20; $sum_rate = 0; $packages = array(); $shipping_info['module'] = $shipment_info['carrier']; foreach ($shipment_info['products'] as $item_id => $amount) { $product = $order_info['products'][$item_id]; $total += $product['subtotal']; $product_extra = db_get_row("SELECT shipping_params, weight FROM ?:products WHERE product_id = ?i", $product['product_id']); if (!empty($product_extra['weight']) && $product_extra['weight'] != 0) { $product_weight = $product_extra['weight']; } else { $product_weight = 0.01; } $p_ship_params = unserialize($product_extra['shipping_params']); $package_length = empty($p_ship_params['box_length']) ? $length : $p_ship_params['box_length']; $package_width = empty($p_ship_params['box_width']) ? $width : $p_ship_params['box_width']; $package_height = empty($p_ship_params['box_height']) ? $height : $p_ship_params['box_height']; $weight_ar = fn_expand_weight($product_weight); $weight = round($weight_ar['plain'] * Registry::get('settings.General.weight_symbol_grams') / 1000, 3); $good['weight'] = $weight; $good['length'] = $package_length; $good['width'] = $package_width; $good['height'] = $package_height; for ($x = 1; $x <= $amount; $x++) { $goods[] = $good; } foreach ($order_info['product_groups'] as $product_groups) { if (!empty($product_groups['products'][$item_id])) { $products[$item_id] = $product_groups['products'][$item_id]; $products[$item_id] = array_merge($products[$item_id], $good); $products[$item_id]['amount'] = $amount; } $shipping_info['package_info'] = $product_groups['package_info']; } } $data_package = Shippings::groupProductsList($products, $shipping_info['package_info']['location']); $data_package = reset($data_package); $shipping_info['package_info_full'] = $data_package['package_info_full']; $shipping_info['package_info'] = $data_package['package_info_full']; $url = 'http://api.edostavka.ru/calculator/calculate_price_by_json.php'; $r_url = 'http://lk.cdek.ru:8080/calculator/calculate_price_by_json.php'; $post['version'] = '1.0'; $post['dateExecute'] = date('Y-m-d'); if (!empty($shipping_info['service_params']['dateexecute'])) { $timestamp = TIME + $shipping_info['service_params']['dateexecute'] * SECONDS_IN_DAY; $dateexecute = date('Y-m-d', $timestamp); } else { $dateexecute = date('Y-m-d'); } $post['dateExecute'] = $dateexecute; if (!empty($shipping_settings['authlogin'])) { $post['authLogin'] = $shipping_info['service_params']['authlogin']; $post['secure'] = !empty($shipping_info['service_params']['authpassword']) ? md5($post['dateExecute'] . "&" . $shipping_info['service_params']['authpassword']) : ''; } $post['authLogin'] = $shipping_info['service_params']['authlogin']; $post['secure'] = md5($post['dateExecute'] . "&" . $shipping_info['service_params']['authpassword']); $post['senderCityId'] = $shipping_info['service_params']['from_city_id']; $post['receiverCityId'] = $rec_city_code; $post['tariffId'] = $shipping_info['service_params']['tariffid']; $post['goods'] = $goods; $post = json_encode($post); $key = md5($post); $sdek_data = fn_get_session_data($key); $content = json_encode($post); if (empty($sdek_data)) { $response = Http::post($url, $post, array('Content-Type: application/json', 'Content-Length: ' . strlen($content)), array('timeout' => SDEK_TIMEOUT)); if (empty($response)) { $response = Http::post($r_url, $post, array('Content-Type: application/json', 'Content-Length: ' . strlen($content)), array('timeout' => SDEK_TIMEOUT)); } fn_set_session_data($key, $response); } else { $response = $sdek_data; } $result = json_decode($response, true); $sum_rate = Shippings::calculateRates(array($shipping_info)); $sum_rate = reset($sum_rate); $result = $sum_rate['price']; return $result; }
function fn_calculate_cart_content(&$cart, $auth, $calculate_shipping = 'A', $calculate_taxes = true, $options_style = 'F', $apply_cart_promotions = true) { $shipping_rates = array(); $product_groups = array(); $cart_products = array(); $cart['subtotal'] = $cart['display_subtotal'] = $cart['original_subtotal'] = $cart['amount'] = $cart['total'] = $cart['discount'] = $cart['tax_subtotal'] = 0; $cart['use_discount'] = false; $cart['shipping_required'] = false; $cart['shipping_failed'] = $cart['company_shipping_failed'] = false; $cart['stored_taxes'] = empty($cart['stored_taxes']) ? 'N' : $cart['stored_taxes']; $cart['display_shipping_cost'] = $cart['shipping_cost'] = 0; $cart['coupons'] = empty($cart['coupons']) ? array() : $cart['coupons']; $cart['recalculate'] = isset($cart['recalculate']) ? $cart['recalculate'] : false; $cart['free_shipping'] = array(); $cart['options_style'] = $options_style; $cart['products'] = !empty($cart['products']) ? $cart['products'] : array(); fn_add_exclude_products($cart, $auth); if (isset($cart['products']) && is_array($cart['products'])) { $amount_totals = array(); if (Registry::get('settings.General.disregard_options_for_discounts') == 'Y') { foreach ($cart['products'] as $k => $v) { if (!empty($amount_totals[$v['product_id']])) { $amount_totals[$v['product_id']] += $v['amount']; } else { $amount_totals[$v['product_id']] = $v['amount']; } } } // Collect product data foreach ($cart['products'] as $k => $v) { $cart['products'][$k]['amount_total'] = isset($amount_totals[$v['product_id']]) ? $amount_totals[$v['product_id']] : $v['amount']; $_cproduct = fn_get_cart_product_data($k, $cart['products'][$k], false, $cart, $auth); if (empty($_cproduct)) { // FIXME - for deleted products for OM fn_delete_cart_product($cart, $k); continue; } $cart_products[$k] = $_cproduct; } fn_set_hook('calculate_cart_items', $cart, $cart_products, $auth); // Apply cart promotions if ($apply_cart_promotions == true && $cart['subtotal'] >= 0) { if (!empty($cart['stored_subtotal_discount'])) { $prev_discount = $cart['subtotal_discount']; } $cart['applied_promotions'] = fn_promotion_apply('cart', $cart, $auth, $cart_products); if (!empty($cart['stored_subtotal_discount'])) { $cart['subtotal_discount'] = $prev_discount; } } fn_check_promotion_notices(); if (Registry::get('settings.General.disable_shipping') == 'Y') { $cart['shipping_required'] = false; } if (!empty($cart['change_cart_products'])) { $location = fn_get_customer_location($auth, $cart); $product_groups = Shippings::groupProductsList($cart_products, $location); if (!empty($cart['product_groups']) && count($product_groups) == count($cart['product_groups'])) { foreach ($product_groups as $key_group => $group) { $cart['product_groups'][$key_group]['products'] = $group['products']; } } else { if (!empty($cart['chosen_shipping']) && count($cart['chosen_shipping']) == count($product_groups)) { $cart['calculate_shipping'] = true; } if (!empty($cart['product_groups']) && count($cart['product_groups']) !== count($product_groups)) { unset($cart['product_groups']); } } unset($cart['change_cart_products']); $cart['stored_taxes'] = 'N'; } if (!empty($cart['calculate_shipping']) || empty($cart['product_groups'])) { $location = fn_get_customer_location($auth, $cart); $product_groups = Shippings::groupProductsList($cart_products, $location); $shippings = array(); if ($cart['shipping_required'] !== false) { $cart['shipping_required'] = false; foreach ($product_groups as $key_group => $group) { if ($group['shipping_no_required'] === false) { $cart['shipping_required'] = true; break; } } } foreach ($product_groups as $key_group => $group) { if ($cart['shipping_required'] === false) { $product_groups[$key_group]['free_shipping'] = true; $product_groups[$key_group]['shipping_no_required'] = true; } $product_groups[$key_group]['shippings'] = array(); $shippings_group = Shippings::getShippingsList($group); // Adding a shipping method from the created order, if the shipping is not yet in the list. if (!empty($cart['chosen_shipping']) && !empty($cart['shipping']) && !empty($cart['order_id'])) { foreach ($cart['shipping'] as $shipping) { if (!isset($shippings_group[$shipping['shipping_id']])) { $shippings_group[$shipping['shipping_id']] = $shipping; } } } foreach ($shippings_group as $shipping_id => $shipping) { if (!empty($shipping['service_params']['max_weight_of_box'])) { $_group = Shippings::repackProductsByWeight($group, $shipping['service_params']['max_weight_of_box']); } else { $_group = $group; } $_shipping = $shipping; $_shipping['package_info'] = $_group['package_info']; $_shipping['keys'] = array('group_key' => $key_group, 'shipping_id' => $shipping_id); $shippings[] = $_shipping; $shipping['group_key'] = $key_group; $shipping['rate'] = 0; if (in_array($shipping_id, $cart['free_shipping']) || $group['free_shipping']) { $shipping['free_shipping'] = true; } $product_groups[$key_group]['shippings'][$shipping_id] = $shipping; } } if (!empty($cart['calculate_shipping'])) { $rates = Shippings::calculateRates($shippings); foreach ($rates as $rate) { $g_key = $rate['keys']['group_key']; $sh_id = $rate['keys']['shipping_id']; if ($rate['price'] !== false) { $rate['price'] += !empty($product_groups[$g_key]['package_info']['shipping_freight']) ? $product_groups[$g_key]['package_info']['shipping_freight'] : 0; $product_groups[$g_key]['shippings'][$sh_id]['rate'] = empty($product_groups[$g_key]['shippings'][$sh_id]['free_shipping']) ? $rate['price'] : 0; } else { unset($product_groups[$g_key]['shippings'][$sh_id]); } } } $cart['product_groups'] = $product_groups; } $product_groups =& $cart['product_groups']; // FIXME $cart['shipping_cost'] = 0; $cart['shipping'] = array(); if (empty($cart['chosen_shipping'])) { $cart['chosen_shipping'] = array(); if (fn_allowed_for('ULTIMATE') && Registry::get('settings.Checkout.display_shipping_step') != 'Y' && !empty($cart['calculate_shipping'])) { foreach ($product_groups as $key_group => $group) { if (!empty($group['shippings'])) { $first_shipping = reset($group['shippings']); $cart['chosen_shipping'][$key_group] = $first_shipping['shipping_id']; } } } } $count_shipping_failed = 0; foreach ($product_groups as $key_group => $group) { if (!empty($cart['calculate_shipping']) && (!isset($cart['chosen_shipping'][$key_group]) || empty($group['shippings'][$cart['chosen_shipping'][$key_group]])) && !$group['free_shipping']) { $cart['chosen_shipping'][$key_group] = key($group['shippings']); } if ($group['shipping_no_required']) { unset($cart['chosen_shipping'][$key_group]); } if (!isset($cart['chosen_shipping'][$key_group]) && !$group['free_shipping'] && !$group['shipping_no_required']) { $count_shipping_failed++; $cart['company_shipping_failed'] = true; } foreach ($group['shippings'] as $shipping_id => $shipping) { if (isset($cart['chosen_shipping'][$key_group]) && $cart['chosen_shipping'][$key_group] == $shipping_id) { $cart['shipping_cost'] += $shipping['rate']; } } if (!empty($group['shippings']) && isset($cart['chosen_shipping'][$key_group])) { $shipping = $group['shippings'][$cart['chosen_shipping'][$key_group]]; $shipping_id = $shipping['shipping_id']; if (empty($cart['shipping'][$shipping_id])) { $cart['shipping'][$shipping_id] = $shipping; $cart['shipping'][$shipping_id]['rates'] = array(); } $cart['shipping'][$shipping_id]['rates'][$key_group] = $shipping['rate']; } } $cart['display_shipping_cost'] = $cart['shipping_cost']; if (!empty($product_groups) && count($product_groups) == $count_shipping_failed) { $cart['shipping_failed'] = true; } foreach ($cart['chosen_shipping'] as $key_group => $shipping_id) { if (!empty($product_groups[$key_group]) && !empty($product_groups[$key_group]['shippings'][$shipping_id])) { $shipping = $product_groups[$key_group]['shippings'][$shipping_id]; $shipping['group_name'] = $product_groups[$key_group]['name']; $product_groups[$key_group]['chosen_shippings'] = array($shipping); } else { unset($cart['chosen_shipping'][$key_group]); } } fn_apply_stored_shipping_rates($cart); fn_set_hook('calculate_cart_taxes_pre', $cart, $cart_products, $product_groups, $calculate_taxes, $auth); $calculated_taxes_summary = array(); foreach ($product_groups as $key_group => &$group) { foreach ($group['products'] as $cart_id => $product) { if (!empty($cart_products[$cart_id])) { $group['products'][$cart_id] = $cart_products[$cart_id]; } } // Calculate taxes if ($calculate_taxes == true && $auth['tax_exempt'] != 'Y') { $calculated_taxes = fn_calculate_taxes($cart, $key_group, $group['products'], $group['shippings'], $auth); if (empty($calculated_taxes_summary)) { $calculated_taxes_summary = array(); } foreach ($calculated_taxes as $tax_id => $tax) { if (empty($calculated_taxes_summary[$tax_id])) { $calculated_taxes_summary[$tax_id] = $calculated_taxes[$tax_id]; } else { $calculated_taxes_summary[$tax_id]['tax_subtotal'] += $calculated_taxes[$tax_id]['applies']['S']; $calculated_taxes_summary[$tax_id]['applies']['S'] += $calculated_taxes[$tax_id]['applies']['S']; $calculated_taxes_summary[$tax_id]['tax_subtotal'] += $calculated_taxes[$tax_id]['applies']['P']; $calculated_taxes_summary[$tax_id]['applies']['P'] += $calculated_taxes[$tax_id]['applies']['P']; } } } elseif ($cart['stored_taxes'] != 'Y') { $cart['taxes'] = $cart['tax_summary'] = array(); } unset($group); } fn_apply_calculated_taxes($calculated_taxes_summary, $cart); // /FIXME fn_set_hook('calculate_cart_taxes_post', $cart, $cart_products, $shipping_rates, $calculate_taxes, $auth); $cart['subtotal'] = $cart['display_subtotal'] = 0; fn_update_cart_data($cart, $cart_products); foreach ($cart['products'] as $product_code => $product) { foreach ($product_groups as $key_group => $group) { if (in_array($product_code, array_keys($group['products']))) { $product_groups[$key_group]['products'][$product_code] = $product; } } } // Calculate totals foreach ($product_groups as $key_group => $group) { foreach ($group['products'] as $product_code => $product) { $_tax = !empty($product['tax_summary']) ? $product['tax_summary']['added'] / $product['amount'] : 0; $cart_products[$product_code]['display_price'] = $cart_products[$product_code]['price'] + (Registry::get('settings.Appearance.cart_prices_w_taxes') == 'Y' ? $_tax : 0); $cart_products[$product_code]['subtotal'] = $cart_products[$product_code]['price'] * $product['amount']; $cart_products[$product_code]['display_subtotal'] = $cart_products[$product_code]['display_price'] * $product['amount']; if (!empty($product['tax_summary'])) { $cart_products[$product_code]['tax_summary'] = $product['tax_summary']; } $cart['subtotal'] += $cart_products[$product_code]['subtotal']; $cart['display_subtotal'] += $cart_products[$product_code]['display_subtotal']; $cart['products'][$product_code]['display_price'] = $cart_products[$product_code]['display_price']; $product_groups[$key_group]['products'][$product_code]['display_price'] = $cart_products[$product_code]['display_price']; $cart['tax_subtotal'] += !empty($product['tax_summary']) ? $product['tax_summary']['added'] : 0; $cart['total'] += ($cart_products[$product_code]['price'] - 0) * $product['amount']; if (!empty($product['discount'])) { $cart['discount'] += $product['discount'] * $product['amount']; } } } if (Registry::get('settings.General.tax_calculation') == 'subtotal') { $cart['tax_subtotal'] += !empty($cart['tax_summary']['added']) ? $cart['tax_summary']['added'] : 0; } $cart['subtotal'] = fn_format_price($cart['subtotal']); $cart['display_subtotal'] = fn_format_price($cart['display_subtotal']); $cart['total'] += $cart['tax_subtotal']; $cart['total'] = fn_format_price($cart['total'] + $cart['shipping_cost']); if (!empty($cart['subtotal_discount'])) { $cart['total'] -= $cart['subtotal_discount'] < $cart['total'] ? $cart['subtotal_discount'] : $cart['total']; } } /** * Processes cart data after calculating all prices and other data (taxes, shippings etc) * * @param array $cart Cart data * @param array $cart_products Cart products * @param array $auth Auth data * @param string $calculate_shipping // 1-letter flag * A - calculate all available methods * E - calculate selected methods only (from cart[shipping]) * S - skip calculation * @param bool $calculate_taxes Flag determines if taxes should be calculated * @param bool $apply_cart_promotions Flag determines if promotions should be applied to the cart */ fn_set_hook('calculate_cart', $cart, $cart_products, $auth, $calculate_shipping, $calculate_taxes, $apply_cart_promotions); if (!empty($cart['calculate_shipping']) || empty($cart['product_groups'])) { $cart['product_groups'] = $product_groups; } $cart['recalculate'] = false; $cart['calculate_shipping'] = false; /** * Processes cart data after calculating all prices and other data (taxes, shippings etc) including products group * * @param array $cart Cart data * @param array $auth Auth data * @param string $calculate_shipping // 1-letter flag * A - calculate all available methods * E - calculate selected methods only (from cart[shipping]) * S - skip calculation * @param bool $calculate_taxes Flag determines if taxes should be calculated * @param string $options_style 1-letter flag * "F" - Full option information (with exceptions) * "I" - Short info * "" - "Source" info. Only ids array (option_id => variant_id) * @param bool $apply_cart_promotions Flag determines if promotions should be applied to the cart * @param array $cart_products Cart products * @param array $product_groups Products grouped by packages, suppliers, vendors */ fn_set_hook('calculate_cart_post', $cart, $auth, $calculate_shipping, $calculate_taxes, $options_style, $apply_cart_promotions, $cart_products, $product_groups); return array($cart_products, $product_groups); }
function fn_get_ebay_orders() { $success_orders = $failed_orders = array(); setlocale(LC_TIME, 'en_US'); $params = array('OrderStatus' => 'Completed'); $last_transaction = db_get_field('SELECT timestamp FROM ?:ebay_cached_transactions WHERE type = ?s AND status = ?s ORDER BY timestamp DESC', 'orders', 'C'); // Need user_id if (!empty($last_transaction)) { $params['CreateTimeFrom'] = gmstrftime("%Y-%m-%dT%H:%M:%S", $last_transaction); $params['CreateTimeTo'] = gmstrftime("%Y-%m-%dT%H:%M:%S", TIME); } $data = array('timestamp' => TIME, 'user_id' => $_SESSION['auth']['user_id'], 'session_id' => Session::getId(), 'status' => 'A', 'type' => 'orders', 'result' => '', 'site_id' => 0); $transaction_id = db_query('INSERT INTO ?:ebay_cached_transactions ?e', $data); list(, $ebay_orders) = Ebay::instance()->GetOrders($params); $data = array('status' => 'C', 'result' => count($ebay_orders)); db_query('UPDATE ?:ebay_cached_transactions SET ?u WHERE transaction_id = ?i', $data, $transaction_id); if (!empty($ebay_orders)) { foreach ($ebay_orders as $k => $v) { $item_transactions = $v['TransactionArray']; $cart = $products = array(); if (!is_array($item_transactions)) { $item_transactions = array($item_transactions->Transaction); } $i = 1; foreach ($item_transactions as $item) { $email = (string) $item->Buyer->Email; break; } $shipping_address = $v['ShippingAddress']; $customer_name = explode(' ', (string) $shipping_address->Name); $firstname = array_shift($customer_name); $lastname = implode(' ', $customer_name); $cart = array('user_id' => 0, 'company_id' => Registry::get('runtime.company_id'), 'email' => $email, 'ebay_order_id' => $v['OrderID'], 'status' => 'P', 'timestamp' => strtotime($v['CreatedTime']), 'payment_id' => 0, 'user_data' => array('firstname' => $firstname, 'lastname' => $lastname, 'phone' => (string) $shipping_address->Phone, 's_firstname' => $firstname, 's_lastname' => $lastname, 's_address' => (string) $shipping_address->Street1, 's_city' => (string) $shipping_address->CityName, 's_state' => (string) $shipping_address->StateOrProvince, 's_country' => (string) $shipping_address->Country, 's_phone' => (string) $shipping_address->Phone, 's_zipcode' => (string) $shipping_address->PostalCode, 'b_firstname' => $firstname, 'b_lastname' => $lastname, 'b_address' => (string) $shipping_address->Street1, 'b_city' => (string) $shipping_address->CityName, 'b_state' => (string) $shipping_address->StateOrProvince, 'b_country' => (string) $shipping_address->Country, 'b_phone' => (string) $shipping_address->Phone, 'b_zipcode' => (string) $shipping_address->PostalCode), 'total' => $v['Total'], 'subtotal' => $v['Subtotal'], 'shipping_cost' => (double) $v['ShippingServiceSelected']->ShippingServiceCost); foreach ($item_transactions as $item) { $_item = (array) $item->Item; $product_id = db_get_field('SELECT product_id FROM ?:ebay_template_products WHERE ebay_item_id = ?i', $_item['ItemID']); // Need check company_id if (!$product_id) { continue; } $product = fn_get_product_data($product_id, $cart['user_data']); $extra = array("product_options" => array()); $options = db_get_array('SELECT ?:product_options.option_id, ?:product_options_descriptions.option_name, ?:product_option_variants_descriptions.variant_id, ?:product_option_variants_descriptions.variant_name FROM ?:product_options JOIN ?:product_option_variants ON ?:product_option_variants.option_id = ?:product_options.option_id JOIN ?:product_options_descriptions ON ?:product_options_descriptions.option_id = ?:product_options.option_id JOIN ?:product_option_variants_descriptions ON ?:product_option_variants_descriptions.variant_id = ?:product_option_variants.variant_id WHERE product_id =?i', $product_id); if (isset($item->Variation)) { $variations_xml = (array) $item->Variation->VariationSpecifics; if (isset($variations_xml['NameValueList']->Name)) { $variations = (array) $variations_xml['NameValueList']; } else { foreach ($variations_xml['NameValueList'] as $variation) { $variations[] = (array) $variation; } } if (isset($variations)) { if (isset($variations['Name'])) { foreach ($options as $option) { if ($variations['Name'] == $option['option_name'] && $variations['Value'] == $option['variant_name']) { $extra['product_options'][$option['option_id']] = $option['variant_id']; } } } else { foreach ($variations as $variation) { foreach ($options as $option) { if ($variation['Name'] == $option['option_name'] && $variation['Value'] == $option['variant_name']) { $extra['product_options'][$option['option_id']] = $option['variant_id']; } } } } $variations = array(); } } $products[$i] = array('product_id' => $product_id, 'amount' => (int) $item->QuantityPurchased, 'price' => (double) $item->TransactionPrice, 'base_price' => (double) $item->TransactionPrice, 'is_edp' => $product['is_edp'], 'edp_shipping' => $product['edp_shipping'], 'free_shipping' => $product['free_shipping'], 'stored_price' => 'Y', 'company_id' => Registry::get('runtime.company_id'), 'extra' => $extra); unset($product); $i += 1; } if (empty($products)) { continue; } $cart['products'] = $products; unset($products); $location = fn_get_customer_location($cart['user_data'], $cart); $cart['product_groups'] = Shippings::groupProductsList($cart['products'], $location); list($order_id, $status) = fn_update_order($cart); if (!empty($order_id)) { fn_change_order_status($order_id, 'P', $status, fn_get_notification_rules(array(), false)); $success_orders[] = $order_id; } else { $failed_orders[] = $cart['ebay_order_id']; } } } return array($success_orders, $failed_orders); }