/** * Displays a template details form specific for an eBay site and selected category options * * @param int $siteId The eBay site to display a template for * @param array $categoryOptions The primary category options to customize the form * @param int $templateId Optional template Id to use to fill the form with * @return string The form HTML */ public function getTemplateForm($siteId, $categoryOptions, $templateId = 0) { // Load eBay XML cache $xmlContent = str_replace('xmlns=', 'ns=', $this->ReadCache($siteId)); $getEbayDetailsXml = new SimpleXMLElement($xmlContent); $currencyId = $this->getCurrencyFromSiteId($siteId); $currency = GetCurrencyById($currencyId); $this->template->assign('currency', $currency); $this->template->assign('currencyToken', $currency['currencystring']); $this->template->assign('options', $categoryOptions); $this->template->assign('auctionDurations', $this->getDurationOptions($categoryOptions['auction_durations'])); $this->template->assign('fixedDurations', $this->getDurationOptions($categoryOptions['fixed_durations'])); $paymentMethods = $categoryOptions['payment_methods']; asort($paymentMethods); $this->template->assign('paymentMethods', $this->getPaymentMethodOptions($paymentMethods)); // location details $this->template->assign('countries', GetCountryListAsIdValuePairs()); // shipping details // Options for shipping services $shippingServiceObj = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ShippingServiceDetails'); $shippingServices = $this->getShippingAsOptions($shippingServiceObj); // Options for handling time $handlingTimeObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/DispatchTimeMaxDetails'); $handlingTimeArray = $this->convertEbayObjectToArray('DispatchTimeMax', 'Description', $handlingTimeObject); // remove the 0 days option as handling time is now required with ebay and 0 isnt valid unset($handlingTimeArray[0]); ksort($handlingTimeArray); $this->template->assign('handlingTimes', $handlingTimeArray); // Retrieving shipping cost type $this->template->assign('domesticShippingCostTypes', $shippingServices['Domestic']['ServiceTypes']); $this->template->assign('internationalShippingCostTypes', $shippingServices['International']['ServiceTypes']); // Shipping service Flat $domesticFlatServices = $shippingServices['Domestic']['Services']['Flat']; // is Pickup offered as a service? remove it from our service list and set it as a template var if (isset($domesticFlatServices['Other']['Pickup'])) { $this->template->assign('domesticPickupAllowed', true); unset($domesticFlatServices['Other']['Pickup']); } $this->template->assign('DomesticShippingServFlat', $domesticFlatServices); $this->template->assign('InternationalShippingServFlat', $shippingServices['International']['Services']['Flat']); // Shipping service Calculated if (!empty($shippingServices['Domestic']['Services']['Calculated'])) { $this->template->assign('DomesticShippingServCalculated', $shippingServices['Domestic']['Services']['Calculated']); } if (!empty($shippingServices['International']['Services']['Calculated'])) { $this->template->assign('InternationalShippingServCalculated', $shippingServices['International']['Services']['Calculated']); } // Shipping Service Package Details - only used for calculated shipping cost type $shippingPackageObj = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ShippingPackageDetails'); $shippingPackageArr = $this->convertEbayObjectToArray('ShippingPackage', 'Description', $shippingPackageObj); $this->template->assign('DomesticShippingPackage', $shippingPackageArr); $this->template->assign('InternationalShippingPackage', $shippingPackageArr); // ship to locations $shippingLocationObj = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ShippingLocationDetails'); $shippingLocationArr = $this->convertEbayObjectToArray('ShippingLocation', 'Description', $shippingLocationObj); asort($shippingLocationArr); $this->template->assign('ShipToLocations', $shippingLocationArr); // additional shipping details $salesTaxStatesObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/TaxJurisdiction'); $salesTaxStatesArray = $this->convertEbayObjectToArray('JurisdictionID', 'JurisdictionName', $salesTaxStatesObject); $this->template->assign('hasSalesTaxStates', !empty($salesTaxStatesArray)); asort($salesTaxStatesArray); $this->template->assign('salesTaxStates', $salesTaxStatesArray); // refund details $refundObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ReturnPolicyDetails/Refund'); if ($refundObject) { $this->template->assign('refundOptions', $this->convertEbayObjectToArray('RefundOption', 'Description', $refundObject)); } $this->template->assign('refundSupported', (bool)$refundObject); $returnsWithinObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ReturnPolicyDetails/ReturnsWithin'); if ($returnsWithinObject) { $this->template->assign('returnsWithinOptions', $this->convertEbayObjectToArray('ReturnsWithinOption', 'Description', $returnsWithinObject)); } $this->template->assign('returnsWithinSupported', (bool)$returnsWithinObject); $returnCostPaidByObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ReturnPolicyDetails/ShippingCostPaidBy'); if ($returnCostPaidByObject) { $this->template->assign('returnCostPaidByOptions', $this->convertEbayObjectToArray('ShippingCostPaidByOption', 'Description', $returnCostPaidByObject)); } $this->template->assign('returnCostPaidBySupported', (bool)$returnCostPaidByObject); $returnDescriptionObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ReturnPolicyDetails/Description'); $this->template->assign('returnDescriptionSupported', (bool)$returnDescriptionObject); // hit counter $availableHitCounters = array ('NoHitCounter','HiddenStyle','BasicStyle','RetroStyle'); $hitCounters = array(); foreach ($availableHitCounters as $counter) { $hitCounters[$counter] = GetLang($counter); } $this->template->assign('hitCounters', $hitCounters); // Paid upgrade options // Gallery Style $availableGalleryOptions = array ('None', 'Gallery', 'Plus', 'Featured'); $galleryOptions = array(); foreach ($availableGalleryOptions as $galleryOption) { $galleryOptions[$galleryOption] = GetLang('EbayGallery' . $galleryOption); } $this->template->assign('galleryOptions', $galleryOptions); // Listing enhancement $listingFeaturesObject = $getEbayDetailsXml->xpath('/GeteBayDetailsResponse/ListingFeatureDetails'); $supportedListingFeatures = array('BoldTitle','Border','FeaturedFirst','FeaturedPlus','GiftIcon','Highlight','HomePageFeatured','ProPack'); $listingFeatures = array(); if (isset($listingFeaturesObject[0])) { foreach ($listingFeaturesObject[0] as $featureCode => $availability) { //@ToDo add support for PowerSellerOnly and TopRatedSellerOnly options if (!in_array($featureCode, $supportedListingFeatures) || $availability != 'Enabled') { continue; } $listingFeatures[$featureCode] = GetLang($featureCode); } } $this->template->assign('listingFeatures', $listingFeatures); // any defaults we should set $this->template->assign('quantityOption', 'one'); $this->template->assign('useItemPhoto', true); $this->template->assign('locationCountry', GetCountryIdByName(GetConfig('CompanyCountry'))); $this->template->assign('locationZip', GetConfig('CompanyZip')); $this->template->assign('locationCityState', GetConfig('CompanyCity') . ', ' . GetConfig('CompanyState')); $this->template->assign('reservePriceOption', 'ProductPrice'); $this->template->assign('reservePriceCustom', $categoryOptions['minimum_reserve_price']); $this->template->assign('startPriceOption', 'ProductPrice'); $this->template->assign('startPriceCustom', 0.01); $this->template->assign('buyItNowPriceOption', 'ProductPrice'); $this->template->assign('buyItNowPriceCalcPrice', 10); $this->template->assign('buyItNowPriceCustom', 0.01); $this->template->assign('fixedBuyItNowPriceOption', 'ProductPrice'); $this->template->assign('fixedBuyItNowPriceCustom', 0.01); $this->template->assign('auctionDuration', 'Days_7'); $this->template->assign('fixedDuration', 'Days_7'); $this->template->assign('useDomesticShipping', false); $this->template->assign('useInternationalShipping', false); $this->template->assign('useSalesTax', false); $this->template->assign('hitCounter', 'BasicStyle'); $this->template->assign('galleryOption', 'Gallery'); $this->template->assign('domesticFlatCount', 0); $this->template->assign('domesticCalcCount', 0); $this->template->assign('internationalFlatCount', 0); $this->template->assign('internationalCalcCount', 0); // assign template specific variables if ($templateId) { $template = new ISC_ADMIN_EBAY_TEMPLATE($templateId); $this->template->assign('currency', $template->getCurrency()); // quantity if ($template->getQuantityToSell() == 1) { $quantityOption = 'one'; } else { $quantityOption = 'more'; $this->template->assign('moreQuantity', $template->getQuantityToSell()); } $this->template->assign('quantityOption', $quantityOption); // item photo $this->template->assign('useItemPhoto', $template->getUseItemPhoto()); // lot size $this->template->assign('lotSize', $template->getLotSize()); // location details $this->template->assign('locationCountry', GetCountryIdByISO2($template->getItemLocationCountry())); $this->template->assign('locationZip', $template->getItemLocationZip()); $this->template->assign('locationCityState', $template->getItemLocationCityState()); // selling method $this->template->assign('sellingMethod', $template->getSellingMethod()); if ($template->getSellingMethod() == self::CHINESE_AUCTION_LISTING) { // reserve price $this->template->assign('useReservePrice', $template->getReservePriceUsed()); $reservePriceOption = 'ProductPrice'; if ($template->getReservePriceUsed()) { $reservePriceOption = $template->getReservePriceOption(); if ($reservePriceOption == 'PriceExtra') { $this->template->assign('reservePriceCalcPrice', $template->getReservePriceCalcPrice()); $this->template->assign('reservePriceCalcOption', $template->getReservePriceCalcOption()); $this->template->assign('reservePriceCalcOperator', $template->getReservePriceCalcOperator()); } elseif ($reservePriceOption == 'CustomPrice') { $this->template->assign('reservePriceCustom', $template->getReservePriceCustomPrice()); } } $this->template->assign('reservePriceOption', $reservePriceOption); // start price $startPriceOption = $template->getStartPriceOption(); if ($startPriceOption == 'PriceExtra') { $this->template->assign('startPriceCalcPrice', $template->getStartPriceCalcPrice()); $this->template->assign('startPriceCalcOption', $template->getStartPriceCalcOption()); $this->template->assign('startPriceCalcOperator', $template->getStartPriceCalcOperator()); } elseif ($startPriceOption == 'CustomPrice') { $this->template->assign('startPriceCustom', $template->getStartPriceCustomPrice()); } $this->template->assign('startPriceOption', $startPriceOption); // buy it now price $this->template->assign('useBuyItNowPrice', $template->getBuyItNowPriceUsed()); $buyItNowPriceOption = 'ProductPrice'; if ($template->getBuyItNowPriceUsed()) { $buyItNowPriceOption = $template->getBuyItNowPriceOption(); if ($buyItNowPriceOption == 'PriceExtra') { $this->template->assign('buyItNowPriceCalcPrice', $template->getBuyItNowPriceCalcPrice()); $this->template->assign('buyItNowPriceCalcOption', $template->getBuyItNowPriceCalcOption()); $this->template->assign('buyItNowPriceCalcOperator', $template->getBuyItNowPriceCalcOperator()); } elseif ($buyItNowPriceOption == 'CustomPrice') { $this->template->assign('buyItNowPriceCustom', $template->getBuyItNowPriceCustomPrice()); } } $this->template->assign('buyItNowPriceOption', $buyItNowPriceOption); $this->template->assign('auctionDuration', $template->getListingDuration()); } else { // Fixed Price Item $fixedBuyItNowPriceOption = $template->getStartPriceOption(); if ($fixedBuyItNowPriceOption == 'PriceExtra') { $this->template->assign('fixedBuyItNowPriceCalcPrice', $template->getStartPriceCalcPrice()); $this->template->assign('fixedBuyItNowPriceCalcOption', $template->getStartPriceCalcOption()); $this->template->assign('fixedBuyItNowPriceCalcOperator', $template->getStartPriceCalcOperator()); } elseif ($fixedBuyItNowPriceOption == 'CustomPrice') { $this->template->assign('fixedBuyItNowPriceCustom', $template->getStartPriceCustomPrice()); } $this->template->assign('fixedBuyItNowPriceOption', $fixedBuyItNowPriceOption); $this->template->assign('fixedDuration', $template->getListingDuration()); } // payment details $this->template->assign('selectedPaymentMethods', $template->getPaymentMethods()); $this->template->assign('paypalEmailAddress', $template->getPayPalEmailAddress()); // domestic shipping $this->template->assign('useDomesticShipping', $template->getUseDomesticShipping()); if ($template->getUseDomesticShipping()) { $settings = $template->getDomesticShippingSettings(); $shippingType = $settings['cost_type']; $this->template->assign('domesticShippingCostType', $shippingType); $services = $template->getDomesticShippingServices(); // flat options if ($shippingType == 'Flat') { $this->template->assign('domesticFlatShippingServices', $services); $this->template->assign('domesticFlatCount', count($services)); } // calculated options else { $service = current($services); $this->template->assign('domesticPackageType', $settings['package_type']); $this->template->assign('domesticCalculatedShippingServices', $services); $this->template->assign('domesticCalcCount', count($services)); } $this->template->assign('domesticFreeShipping', $settings['is_free_shipping']); $this->template->assign('domesticGetItFast', $settings['get_it_fast']); $this->template->assign('domesticLocalPickup', $settings['offer_pickup']); $this->template->assign('domesticHandlingCost', $settings['handling_cost']); } // international shipping $this->template->assign('useInternationalShipping', $template->getUseInternationalShipping()); if ($template->getUseInternationalShipping()) { $settings = $template->getInternationalShippingSettings(); $shippingType = $settings['cost_type']; $this->template->assign('internationalShippingCostType', $shippingType); $services = $template->getInternationalShippingServices(); // flat options if ($shippingType == 'Flat') { $this->template->assign('internationalFlatShippingServices', $services); $this->template->assign('internationalFlatCount', count($services)); } // calculated options else { $service = current($services); $this->template->assign('internationalPackageType', $settings['package_type']); $this->template->assign('internationalCalculatedShippingServices', $services); $this->template->assign('internationalCalcCount', count($services)); } $this->template->assign('internationalFreeShipping', $settings['is_free_shipping']); $this->template->assign('internationalHandlingCost', $settings['handling_cost']); } // other shipping $this->template->assign('handlingTime', $template->getHandlingTime()); $this->template->assign('useSalesTax', $template->getUseSalesTax()); $this->template->assign('salesTaxState', $template->getSalesTaxState()); $this->template->assign('salesTaxPercent', $template->getSalesTaxPercent()); $this->template->assign('salesTaxIncludesShipping', $template->getShippingIncludedInTax()); // other details $this->template->assign('checkoutInstructions', $template->getCheckoutInstructions()); $this->template->assign('acceptReturns', $template->getReturnsAccepted()); $this->template->assign('returnOfferedAs', $template->getReturnOfferedAs()); $this->template->assign('returnsPeriod', $template->getReturnsPeriod()); $this->template->assign('returnCostPaidBy', $template->getReturnCostPaidBy()); $this->template->assign('additionalPolicyInfo', $template->getAdditionalPolicyInfo()); $this->template->assign('hitCounter', $template->getCounterStyle()); $this->template->assign('galleryOption', $template->getGalleryType()); $this->template->assign('selectedListingFeatures', $template->getListingFeatures()); } return $this->template->render('ebay.template.form.details.tpl'); }
/** * Displays the list of supported category features * */ private function getCategoryFeaturesListAction() { $templateId = (int)$_POST['templateId']; $productOptions = $_POST['productOptions']; $originalProductCount = $_POST['originalProductCount']; $productCount = $_POST['productCount']; $output['productOptions'] = $productOptions; $output['productCount'] = $productCount; $message = ''; try { $template = new ISC_ADMIN_EBAY_TEMPLATE($templateId); } catch (Exception $ex) { ISC_JSON::output('', false); } $categoryOptions = $template->getPrimaryCategoryOptions(); $secondaryCategoryOptions = $template->getSecondaryCategoryOptions(); $secCatNotSupportVariations = (isset ($secondaryCategoryOptions['variations_supported']) && $secondaryCategoryOptions['variations_supported'] == 0); // if product variations are not supported in both primary, secondary categories, or the selling method is fixed selling method if ((empty ($categoryOptions['variations_supported']) || $secCatNotSupportVariations) || $template->getSellingMethod() != ISC_ADMIN_EBAY::FIXED_PRICE_LISTING) { $updatedProducts['productIds'] = array(); if ($where = ISC_ADMIN_EBAY_LIST_PRODUCTS::getWhereFromOptions($productOptions)) { $where .= " AND "; } $where .= " p.prodvariationid <= 0 "; $res = ISC_ADMIN_EBAY_LIST_PRODUCTS::getProducts($where); while ($row = $this->db->Fetch($res)) { $updatedProducts['productIds'][] = urlencode('products[]='.$row['productid']); } $validProductCount = count($updatedProducts['productIds']); $invalidProductsCount = $originalProductCount - $validProductCount; if (empty ($validProductCount)) { // all selected products have variation $message = GetLang('VariationInvalidProducts'); $output['productCount'] = 0; $output['productOptions'] = ''; } else if ($validProductCount != $originalProductCount) { // some products couldn't be listed $message = sprintf(GetLang('PartialVariationInvalidProducts'), $invalidProductsCount); $output['productOptions']['productIds'] = implode('&', $updatedProducts['productIds']); $output['productCount'] = $validProductCount; } } // generate a list of features $this->template->assign('secCatSelectedNotSupportVariations', ($secCatNotSupportVariations)); $this->template->assign('categoryOptions', $categoryOptions); $this->template->assign('secondaryCategoryOptionsData', $secondaryCategoryOptions); $this->template->assign('currency', $template->getCurrency()); $this->template->assign('message', $message); $this->template->assign('sellingMethod', $template->getSellingMethod()); $output['html'] = $this->template->render('ebay.template.featureslist.tpl'); ISC_JSON::output('', true, $output); }
/** * Adds an Item element for the specified product and template into the supplied XML element * * @param SimpleXMLElement $xml The XML element to add the item to * @param array $product The array of product data * @param ISC_ADMIN_EBAY_TEMPLATE $template The template to use to add the product */ private static function addItemData(&$xml, $product, $template) { $template->setProductData($product); $productId = $product['productid']; $item = $xml->addChild('Item'); $item->addChild('Site', $template->getSiteCode()); // required details $item->addChild('Country', $template->getItemLocationCountry()); $item->addChild('Currency', $template->getCurrencyCode()); $item->addChild('ListingDuration', $template->getListingDuration()); $item->addChild('ListingType', $template->getSellingMethod()); $item->addChild('Location', $template->getItemLocationCityState()); $item->addChild('PostalCode', $template->getItemLocationZip()); $item->addChild('Title', isc_html_escape($product['prodname'])); $item->addChild('Description', isc_html_escape($product['proddesc'])); $item->addChild('SKU', isc_html_escape($product['prodcode'])); $primaryOptions = $template->getPrimaryCategoryOptions(); // are item specifics supported by the primary category? if (!empty($primaryOptions['item_specifics_supported'])) { $itemSpecifics = null; // brand name if (!empty($product['brandname'])) { $itemSpecifics = $item->addChild('ItemSpecifics'); $specific = $itemSpecifics->addChild('NameValueList'); $specific->addChild('Name', GetLang('Brand')); $specific->addChild('Value', $product['brandname']); } // do we have custom fields for the product? if (!empty($product['custom_fields'])) { if ($itemSpecifics == null) { $itemSpecifics = $item->addChild('ItemSpecifics'); } foreach ($product['custom_fields'] as $customField) { $specific = $itemSpecifics->addChild('NameValueList'); $specific->addChild('Name', $customField['fieldname']); $specific->addChild('Value', $customField['fieldvalue']); } } } // does this product have a upc? it can be used to pull in product information if (!empty($primaryOptions['catalog_enabled']) && !empty($product['upc'])) { $productListingDetails = $item->addChild('ProductListingDetails'); $productListingDetails->addChild('UPC', $product['upc']); } // does the product have a variation? if ($product['prodvariationid']) { $variationId = $product['prodvariationid']; $variations = $item->addChild('Variations'); $variationSpecificsSet = $variations->addChild('VariationSpecificsSet'); $lastOptionName = ''; $variationOptions = array(); // add the variation options $res = Store_Variations::getOptions($variationId); while ($optionRow = $GLOBALS['ISC_CLASS_DB']->Fetch($res)) { if ($optionRow['voname'] != $lastOptionName) { $lastOptionName = $optionRow['voname']; $nameValueList = $variationSpecificsSet->addChild('NameValueList'); $nameValueList->addChild('Name', $lastOptionName); } $nameValueList->addChild('Value', $optionRow['vovalue']); $variationOptions[$optionRow['voptionid']] = array($optionRow['voname'], $optionRow['vovalue']); } // add the combinations $res = Store_Variations::getCombinations($productId, $variationId); while ($comboRow = $GLOBALS['ISC_CLASS_DB']->Fetch($res)) { $variation = $variations->addChild('Variation'); if ($comboRow['vcsku']) { $variation->addChild('SKU', $comboRow['vcsku']); } $variation->addChild('Quantity', $template->getQuantityToSell()); $startPrice = $template->getStartPrice(false); $comboStartPrice = CalcProductVariationPrice($startPrice, $comboRow['vcpricediff'], $comboRow['vcprice']); $comboStartPrice = ConvertPriceToCurrency($comboStartPrice, $template->getCurrency()); $variation->addChild('StartPrice', $comboStartPrice); // add the options for this combination $variationSpecifics = $variation->addChild('VariationSpecifics'); $options = explode(',', $comboRow['vcoptionids']); foreach ($options as $optionId) { list($optionName, $optionValue) = $variationOptions[$optionId]; $nameValueList = $variationSpecifics->addChild('NameValueList'); $nameValueList->addChild('Name', $optionName); $nameValueList->addChild('Value', $optionValue); } } // add images $optionPictures = Store_Variations::getCombinationImagesForFirstOption($productId, $variationId); if (!empty($optionPictures)) { $pictures = $variations->addChild('Pictures'); // we'll be adding images for the first option set list($optionName) = current($variationOptions); $pictures->addChild('VariationSpecificName', $optionName); foreach ($optionPictures as $optionName => $imageUrl) { $variationSpecificPictureSet = $pictures->addChild('VariationSpecificPictureSet'); $variationSpecificPictureSet->addChild('VariationSpecificValue', $optionName); $variationSpecificPictureSet->addChild('PictureURL', $imageUrl); } } } // add quantity if (!$product['prodvariationid']) { $item->addChild('Quantity', $template->getTrueQuantityToSell()); } $item->addChild('PrivateListing', (int)$template->isPrivateListing()); // schedule date if ($template->getScheduleDate()) { $item->addChild('ScheduleTime', $template->getScheduleDate()); } // condition if ($template->getItemCondition()) { $item->addChild('ConditionID', $template->getItemCondition()); } // payment details foreach ($template->getPaymentMethods() as $paymentMethod) { $item->addChild('PaymentMethods', $paymentMethod); } if (in_array('PayPal', $template->getPaymentMethods())) { $item->addChild('PayPalEmailAddress', $template->getPayPalEmailAddress()); } // add categories $item->addChild('PrimaryCategory')->addChild('CategoryID', $template->getPrimaryCategoryId()); if ($template->getSecondaryCategoryId()) { $item->addChild('SecondaryCategory')->addChild('CategoryID', $template->getSecondaryCategoryId()); } $item->addChild('CategoryMappingAllowed', (int)$template->getAllowCategoryMapping()); // add store categories if ($template->getPrimaryStoreCategoryId()) { $storeFront = $item->addChild('Storefront'); $storeFront->addChild('StoreCategoryID', $template->getPrimaryStoreCategoryId()); if ($template->getSecondaryStoreCategoryId()) { $storeFront->addChild('StoreCategory2ID', $template->getSecondaryStoreCategoryId()); } } // prices if ($template->getSellingMethod() == ISC_ADMIN_EBAY::CHINESE_AUCTION_LISTING) { $item->addChild('StartPrice', $template->getStartPrice()); if ($template->getReservePrice() !== false) { $item->addChild('ReservePrice', $template->getReservePrice()); } if ($template->getBuyItNowPrice() !== false) { $item->addChild('BuyItNowPrice', $template->getBuyItNowPrice()); } } elseif (!$product['prodvariationid']) { $item->addChild('StartPrice', $template->getStartPrice()); } // add return policy info $policy = $item->addChild('ReturnPolicy'); $policy->addChild('ReturnsAcceptedOption', $template->getReturnsAcceptedOption()); if ($template->getReturnsAccepted()) { if ($template->getAdditionalPolicyInfo()) { $policy->addChild('Description', isc_html_escape($template->getAdditionalPolicyInfo())); } if ($template->getReturnOfferedAs()) { $policy->addChild('RefundOption', $template->getReturnOfferedAs()); } if ($template->getReturnsPeriod()) { $policy->addChild('ReturnsWithinOption', $template->getReturnsPeriod()); } if ($template->getReturnCostPaidBy()) { $policy->addChild('ShippingCostPaidByOption', $template->getReturnCostPaidBy()); } } // counter $item->addChild('HitCounter', $template->getCounterStyle()); // gallery option $pictureDetails = $item->addChild('PictureDetails'); $pictureDetails->addChild('GalleryType', $template->getGalleryType()); if ($template->getGalleryType() == 'Featured') { $pictureDetails->addChild('GalleryDuration', $template->getFeaturedGalleryDuration()); } if ($template->getItemPhoto()) { if ($template->getGalleryType() != 'None') { $pictureDetails->addChild('GalleryURL', $template->getItemPhoto()); } $pictureDetails->addChild('PictureURL', $template->getItemPhoto()); } // listing features foreach ($template->getListingFeatures() as $feature) { $item->addChild('ListingEnhancement', $feature); } // domestic shipping if ($template->getUseDomesticShipping()) { // add shipping details $shippingDetails = $item->addChild('ShippingDetails'); // the actual shipping type - Flat or Calculated - where's our freight option gone? $shippingDetails->addChild('ShippingType', $template->getShippingType()); //$insuranceDetails = $shippingDetails->addChild('InsuranceDetails'); $shippingDetails->addChild('InsuranceOption', 'NotOffered'); $calculatedRate = null; // add checkout instructions if ($template->getCheckoutInstructions()) { $shippingDetails->addChild('PaymentInstructions', $template->getCheckoutInstructions()); } // add sales tax - US only if ($template->getUseSalesTax()) { $salesTax = $shippingDetails->addChild('SalesTax'); $salesTax->addChild('SalesTaxState', $template->getSalesTaxState()); $salesTax->addChild('SalesTaxPercent', $template->getSalesTaxPercent()); $salesTax->addChild('ShippingIncludedInTax', $template->getShippingIncludedInTax()); } $domesticServices = $template->getDomesticShippingServices(); $domesticSettings = $template->getDomesticShippingSettings(); if (empty($domesticSettings)) { throw new Exception('Missing domestic shipping settings'); } // add a pickup service - can't get this to work gives error: ShippingService is required if Insurance, SalesTax, or AutoPay is specified. (10019) if ($domesticSettings['offer_pickup']) { $domesticServices['Pickup'] = array( 'additional_cost' => 0, 'cost' => 0 //(double)$domesticServices['pickup_cost'] // where has this option gone? ); } if (empty($domesticServices)) { throw new Exception('Missing domestic shipping services'); } $domesticFeeShipping = (bool)$domesticSettings['is_free_shipping']; // add our domestic services self::addShippingServices($shippingDetails, $domesticSettings, $domesticServices, 'ShippingServiceOptions', $domesticFeeShipping); // buy it fast enabled? domestic only if ($domesticSettings['get_it_fast']) { $item->addChild('GetItFast', true); $item->addChild('DispatchTimeMax', 1); // required for getitfast } else { // add handling time $item->addChild('DispatchTimeMax', $template->getHandlingTime()); } if ($domesticSettings['cost_type'] == 'Calculated') { if ($calculatedRate == null) { $calculatedRate = self::addCalculatedDetails($shippingDetails, $template); } // handling cost if ($domesticSettings['handling_cost']) { $calculatedRate->addChild('PackagingHandlingCosts', $domesticSettings['handling_cost']); } } // international shipping - we can't supply international services if we don't specify domestic if ($template->getUseInternationalShipping()) { $internationalSettings = $template->getInternationalShippingSettings(); $internationalServices = $template->getInternationalShippingServices(); if (empty($internationalSettings)) { throw new Exception('Missing international shipping settings'); } if (empty($internationalServices)) { throw new Exception('Missing international shipping services'); } // add our international services self::addShippingServices($shippingDetails, $internationalSettings, $internationalServices, 'InternationalShippingServiceOption', false, true); if ($internationalSettings['cost_type'] == 'Calculated') { if ($calculatedRate == null) { $calculatedRate = self::addCalculatedDetails($shippingDetails, $template); } // handling cost if ($internationalSettings['handling_cost']) { $calculatedRate->addChild('InternationalPackagingHandlingCosts', $internationalSettings['handling_cost']); } } } } else { // domestic pickup only $item->addChild('ShipToLocations', 'None'); } }