function fn_exim_get_product_option_exception($product_id, $combination, $set_delimiter, $lang_code = CART_LANGUAGE)
{
    $result = array();
    if (empty($combination)) {
        return '';
    }
    $product_options = fn_get_product_options($product_id, $lang_code);
    if (empty($product_options)) {
        return '';
    }
    $combination = unserialize($combination);
    foreach ($combination as $option_id => $variant_id) {
        switch ($variant_id) {
            case '-1':
                // Any variant can be selected
                $result[] = fn_exim_wrap_value($product_options[$option_id]['option_name'], "|", '=') . '=#Any';
                break;
            case '-2':
                // No variants can be selected
                $result[] = fn_exim_wrap_value($product_options[$option_id]['option_name'], "|", '=') . '=#No';
                break;
            default:
                // Specified variant
                $result[] = fn_exim_wrap_value($product_options[$option_id]['option_name'], "|", '=') . '=' . fn_exim_wrap_value($product_options[$option_id]['variants'][$variant_id]['variant_name'], "|", '=');
                break;
        }
    }
    $result = implode($set_delimiter, fn_exim_wrap_value($result, "'", $set_delimiter));
    return $result;
}
function fn_exim_get_product_combination($product_id, $combination, $set_delimiter, $lang_code = CART_LANGUAGE)
{
    $selected_options = fn_get_product_options_by_combination($combination);
    $options = fn_get_selected_product_options($product_id, $selected_options, $lang_code);
    $return = array();
    if (!empty($options)) {
        foreach ($options as $option) {
            if (isset($selected_options[$option['option_id']])) {
                $str = fn_exim_wrap_value($option['option_name'], "|", ':') . ': ';
                $str .= fn_exim_wrap_value($option['variants'][$selected_options[$option['option_id']]]['variant_name'], "|", ':');
                $return[] = $str;
            }
        }
    }
    return implode($set_delimiter, fn_exim_wrap_value($return, "'", $set_delimiter));
}
function fn_exim_get_product_features_variants($feature_id, $lang_code)
{
    list($feature_variants) = fn_get_product_feature_variants(array('feature_id' => $feature_id), 0, $lang_code);
    $variants = array();
    foreach ($feature_variants as $variant) {
        $variants[] = fn_exim_wrap_value($variant['variant'], "'", ',');
    }
    $variants = implode(', ', $variants);
    return $variants;
}
function fn_exim_get_taxes($product_taxes, $lang_code = '')
{
    $taxes = db_get_fields("SELECT tax FROM ?:tax_descriptions WHERE FIND_IN_SET(tax_id, ?s) AND lang_code = ?s", $product_taxes, $lang_code);
    return implode(', ', fn_exim_wrap_value($taxes, "'", ','));
}
Example #5
0
/**
 * Wrap value
 * @param string|string[] $value
 * @param string $enclosure
 * @param string $delimiter
 * @return string|string[]
 */
function fn_exim_wrap_value($value, $enclosure = '"', $delimiter = ',')
{
    $enclosure = trim($enclosure);
    $delimiter = trim($delimiter);
    if (is_array($value)) {
        foreach ($value as &$item) {
            $item = fn_exim_wrap_value($item, $enclosure, $delimiter);
        }
        unset($item);
        return $value;
    }
    if (is_string($value) && strpos($value, $delimiter) !== false) {
        $value = $enclosure . str_replace($enclosure, $enclosure . $enclosure, $value) . $enclosure;
    }
    return $value;
}