/** * 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'); }