Beispiel #1
0
function fn_prepare_xml_product_features($features)
{
    $product_features = '';
    if (!empty($features) && is_array($features)) {
        foreach ($features as $k => $feature) {
            $value = '';
            if ($feature['feature_type'] == 'G' && !empty($feature['subfeatures'])) {
                $product_features .= fn_prepare_xml_product_features($feature['subfeatures']);
                continue;
            } else {
                if ($feature['feature_type'] == 'C' && $feature['value'] == 'Y') {
                    $value = __('yes');
                } elseif ($feature['feature_type'] == 'D') {
                    $value = strftime(Settings::instance()->getValue('date_format', 'Appearance'), $feature['value_int']);
                } elseif ($feature['feature_type'] == 'M' && $feature['variants']) {
                    foreach ($feature['variants'] as $var) {
                        if ($var['selected']) {
                            $variants[] = $var['variant'];
                        }
                    }
                    $value = implode("</Value>\n<Value>", $variants);
                } elseif ($feature['feature_type'] == 'S' || $feature['feature_type'] == 'E') {
                    foreach ($feature['variants'] as $var) {
                        if ($var['selected']) {
                            $value = $var['variant'];
                        }
                    }
                } elseif ($feature['feature_type'] == 'N' || $feature['feature_type'] == 'O') {
                    $value = floatval($feature['value_int']);
                } else {
                    $value = htmlentities($feature['value']);
                }
                $product_features .= <<<EOT

                    <NameValueList>
                        <Name>{$feature['description']}</Name>
                        <Value>{$value}</Value>
                    </NameValueList>

EOT;
            }
        }
    }
    return $product_features;
}
Beispiel #2
0
    private function _getBaseItemData($product, $template, $images_data)
    {
        $currency = CART_PRIMARY_CURRENCY;
        $shippings = $this->prepareShipping($product, $template);
        $company = fn_get_company_placement_info(Registry::get('runtime.company_id'));
        $price = fn_format_price($product['price']);
        $picture_details = '';
        if ($product['override'] == "Y") {
            $title = substr(strip_tags($product['ebay_title']), 0, 80);
            $description = !empty($product['ebay_description']) ? $product['ebay_description'] : $product['full_description'];
        } else {
            $title = substr(strip_tags($product['product']), 0, 80);
            $description = $product['full_description'];
        }
        $payments = '<PaymentMethods>' . implode("</PaymentMethods>\n<PaymentMethods>", $template['payment_methods']) . '</PaymentMethods>';
        if (in_array('PayPal', $template['payment_methods'])) {
            $payments .= "\n<PayPalEmailAddress>{$template['paypal_email']}</PayPalEmailAddress>";
        }
        if (!empty($product['main_pair']) && !empty($product['main_pair']['detailed']) && !empty($product['main_pair']['detailed']['http_image_path']) && $images_data[md5($product['main_pair']['detailed']['http_image_path'])]) {
            $image_url = $images_data[md5($product['main_pair']['detailed']['http_image_path'])];
            $picture_details .= "<PictureURL>{$image_url}</PictureURL>\n";
        }
        if ($product['image_pairs']) {
            foreach ($product['image_pairs'] as $image_pair) {
                if (!empty($images_data[md5($image_pair['detailed']['http_image_path'])])) {
                    $image_url = $images_data[md5($image_pair['detailed']['http_image_path'])];
                    $picture_details .= "<PictureURL>{$image_url}</PictureURL>\n";
                }
            }
        }
        $picture_details = empty($picture_details) ? '' : "<PictureDetails>\n{$picture_details}</PictureDetails>";
        $product_features = '';
        if (!empty($product['product_features'])) {
            $product_features = '<ItemSpecifics>' . fn_prepare_xml_product_features($product['product_features']) . '</ItemSpecifics>';
        }
        $product_options = '';
        $start_price = '';
        $product_quantity = '';
        $inventory_combinations = db_get_array("SELECT combination FROM ?:product_options_inventory WHERE product_id = ?i AND amount > 0 AND combination != ''", $product['product_id']);
        if (!empty($product['product_options']) && !empty($inventory_combinations)) {
            $params = array('page' => 1, 'product_id' => $product['product_id']);
            $product_options = '<Variations>' . fn_prepare_xml_product_options($params, $product, $images_data) . '</Variations>';
        }
        if (empty($product_options)) {
            $start_price = '<StartPrice currencyID="' . $currency . '">' . $price . '</StartPrice>';
            $product_quantity = '<Quantity>' . $product['amount'] . '</Quantity>';
        }
        $location = fn_get_country_name($company['company_country']);
        $xml = <<<EOT
<ItemID>{$product['ebay_item_id']}</ItemID>
<Site>{$template['site']}</Site>
<ListingType>FixedPriceItem</ListingType>
<Currency>{$currency}</Currency>
<PrimaryCategory>
<CategoryID>{$template['category']}</CategoryID>
</PrimaryCategory>
<SecondaryCategory>
<CategoryID>{$template['sec_category']}</CategoryID>
</SecondaryCategory>
<ConditionID>{$template['condition_id']}</ConditionID>
<CategoryMappingAllowed>true</CategoryMappingAllowed>
<Country>{$company['company_country']}</Country>
<PostalCode>{$company['company_zipcode']}</PostalCode>
<Location>{$location}</Location>
<Title><![CDATA[{$title}]]></Title>
<Description><![CDATA[{$description}]]></Description>
{$payments}
<ListingDuration>{$template['ebay_duration']}</ListingDuration>
<DispatchTimeMax>{$template['dispatch_days']}</DispatchTimeMax>
{$shippings}
{$picture_details}
{$product_features}
{$product_options}
{$start_price}
{$product_quantity}
EOT;
        return $xml;
    }
Beispiel #3
0
function fn_prepare_xml_product_features($features)
{
    $product_features = '';
    if (!empty($features) && is_array($features)) {
        foreach ($features as $k => $feature) {
            $value = '';
            if ($feature['feature_type'] == ProductFeatures::GROUP && !empty($feature['subfeatures'])) {
                $product_features .= fn_prepare_xml_product_features($feature['subfeatures']);
                continue;
            } else {
                if ($feature['feature_type'] == ProductFeatures::SINGLE_CHECKBOX && $feature['value'] == 'Y') {
                    $value = __('yes');
                } elseif ($feature['feature_type'] == ProductFeatures::DATE) {
                    $value = strftime(Settings::instance()->getValue('date_format', 'Appearance'), $feature['value_int']);
                } elseif ($feature['feature_type'] == ProductFeatures::MULTIPLE_CHECKBOX && $feature['variants']) {
                    foreach ($feature['variants'] as $var) {
                        if ($var['selected']) {
                            $variants[] = $var['variant'];
                        }
                    }
                    $value = implode("</Value>\n<Value>", $variants);
                } elseif ($feature['feature_type'] == ProductFeatures::TEXT_SELECTBOX || $feature['feature_type'] == ProductFeatures::EXTENDED) {
                    foreach ($feature['variants'] as $var) {
                        if ($var['selected']) {
                            $value = $var['variant'];
                        }
                    }
                } elseif ($feature['feature_type'] == ProductFeatures::NUMBER_SELECTBOX || $feature['feature_type'] == ProductFeatures::NUMBER_FIELD) {
                    $value = floatval($feature['value_int']);
                } else {
                    $from = array("&", "'", "<", ">", "\"");
                    $to = array("&amp;", "&apos;", "&lt;", "&gt;", "&quot;");
                    $value = str_replace($from, $to, $feature['value']);
                }
                $product_features .= <<<EOT

                    <NameValueList>
                        <Name>{$feature['description']}</Name>
                        <Value>{$value}</Value>
                    </NameValueList>

EOT;
            }
        }
    }
    return $product_features;
}