function cw_get_products_taxes(&$product, $user_info, $calculate_discounted_price = false, $taxes = '', $include_in_any_case = false)
{
    global $config;
    $amount = $product['amount'] > 0 ? $product['amount'] : 1;
    $clear_price = $product['price'];
    if ($calculate_discounted_price && isset($product['discounted_price'])) {
        $tps = $taxed_price = $product['discounted_price'] / $amount;
    } else {
        $tps = $taxed_price = $product['price'];
    }
    if (empty($taxes)) {
        $taxes = cw_get_product_tax_rates($product, $user_info, $include_in_any_case);
    }
    if ($include_in_any_case && is_array($taxes)) {
        foreach ($taxes as $k => $v) {
            $taxes[$k]['display_including_tax'] = 1;
        }
    }
    $clear_price = cw_taxes_price_without_tax($product['price'], $taxes);
    if ($product['free_tax'] == 'Y') {
        $taxes_ = $taxes;
    } else {
        $taxes_ = cw_taxes_calc_simple($taxed_price, $taxes, $amount);
    }
    if ($clear_price != $tps && $product['free_tax'] != 'Y') {
        $taxes_ = cw_taxes_calc_simple($clear_price, $taxes, $amount);
    } else {
        $clear_price = $taxed_price;
    }
    $product['taxed_price'] = price_format($taxed_price, true);
    $product['taxed_clear_price'] = price_format($clear_price, true);
    $product['display_price'] = $clear_price;
    return $taxes_;
}
 $doc_data = cw_doc_get($doc_id, 0);
 $product_id = $aom_orders[$doc_id]['products'][$index]['product_id'];
 $v = $product_details[$index];
 $v['amount'] = intval($v['amount']);
 $count_product_in_stock = cw_aom_get_quantity_in_stock($aom_orders[$doc_id]['products'][$index]['warehouse_customer_id'], $product_id, $doc_data['order']['status'], $v['product_options'], $doc_data['products'][$index]);
 if ($is_old) {
     $count_product_in_stock += $v['amount'];
 }
 # kornev
 # pos orders && supplier orders are unlimited
 if ($v['amount'] > 0) {
     $aom_orders[$doc_id]['products'][$index]['amount'] = $config['unlimited_products'] ? $v['amount'] : min($v['amount'], $count_product_in_stock);
 }
 $v['price'] = cw_aom_validate_price($v['price']);
 if ($config['Taxes']['display_taxed_order_totals'] == 'Y') {
     $v['price'] = cw_taxes_price_without_tax($v['price'], $aom_orders[$doc_id]['products'][$index]['taxes']);
 }
 $product_options_result = array();
 # kornev, TOFIX
 if ($v['product_options'] && $addons['product_options']) {
     if (!cw_check_product_options($product_id, $v['product_options'])) {
         $v['product_options'] = cw_get_default_options($product_id, $v['amount'], $aom_orders[$doc_id]['userinfo']['membership_id']);
     }
     list($variant, $product_options_result) = cw_get_product_options_data($product_id, $v['product_options'], $aom_orders[$doc_id]['userinfo']['membership_id']);
     $aom_orders[$doc_id]['products'][$index]['options_surcharge'] = 0;
     if ($product_options_result) {
         foreach ($product_options_result as $key => $o) {
             $aom_orders[$doc_id]['products'][$index]['options_surcharge'] += $o['modifier_type'] == '%' ? $v['price'] * $o['price_modifier'] / 100 : $o['price_modifier'];
         }
     }
 }