/** * Lists up to 5 items with eBay * * @param array $products An array of products to list * @param ISC_ADMIN_EBAY_TEMPLATE $template The template to list the product with * @return array Array of ISC_ADMIN_EBAY_LIST_ITEM_RESULT objects for each item listed */ public static function listItems($products, $template) { ISC_ADMIN_EBAY_OPERATIONS::setSiteId($template->getSiteId()); $results = array(); $regularProducts = array(); // any products with a variation should be listed separately with a FixedPriceItem request foreach ($products as $productId => $product) { if ($product['prodvariationid']) { try { $xml = ISC_ADMIN_EBAY_OPERATIONS::addFixedPriceItem($product, $template); } catch (ISC_EBAY_API_REQUEST_EXCEPTION $ex) { $xml = $ex->getResponseXML(); } $results[] = new ISC_ADMIN_EBAY_LIST_ITEM_RESULT($product, $xml); } else { $regularProducts[$productId] = $product; } } // process the remainder of the items if (!empty($regularProducts)) { try { $xml = ISC_ADMIN_EBAY_OPERATIONS::addItems($regularProducts, $template); } catch (ISC_EBAY_API_REQUEST_EXCEPTION $ex) { $xml = $ex->getResponseXML(); // if we have item level data then we want to process the results to get any errors for each item // otherwise, throw the exception and it will get caught in the job as a per-request level error if (!isset($xml->AddItemResponseContainer)) { throw $ex; } } // process each add item response foreach ($xml->AddItemResponseContainer as $item) { $productId = (int)$item->CorrelationID; $results[] = new ISC_ADMIN_EBAY_LIST_ITEM_RESULT($regularProducts[$productId], $item); } } return $results; }
/** * 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); }
public function perform() { // validate the listing if (!$this->_validateListing()) { $this->_logDebug('Listing validation failed.'); $this->_removeListing(); return; } $templateId = $this->_getListingData('templateid'); $where = $this->_getListingData('where'); $offset = $this->_getListingData('offset'); $listingDate = $this->_getListingData('listing_date'); $scheduleDate = $this->_getListingData('schedule_date'); $this->_logDebug('listing template Id ' . $templateId . ' starting from row ' . $offset . ' with batch size ' . self::BATCH_SIZE); // get the template object try { $template = new ISC_ADMIN_EBAY_TEMPLATE($templateId); } catch (Exception $ex) { $error = GetLang('Ebay_Listing_Log_TemplateNotFound', array('id' => $templateId)); $this->_logError($error); $this->_errorListing($error); $this->_endListing(); return; } $primaryOptions = $template->getPrimaryCategoryOptions(); $secondaryOptions = $template->getSecondaryCategoryOptions(); // did the user choose to schedule the listing for a future date? if ($listingDate == 'schedule') { $template->setScheduleDate($scheduleDate); } // query for the products to export $query = ISC_ADMIN_EBAY_LIST_PRODUCTS::getListQuery($where, self::BATCH_SIZE, $offset); $this->_logDebug('query', $query); $res = $this->_db->Query($query); if (!$res) { $error = GetLang('Ebay_Listing_Log_JobDatabaseError'); $this->_logError($error); $this->_errorListing($error); $this->_endListing(); return; } $successCount = 0; $warningCount = 0; $errorCount = 0; $connectFailCount = 0; // nothing left to list? $resultCount = $this->_db->CountResult($res); if ($resultCount == 0) { $this->_logDebug('no more items to list'); $this->_endListing(); return; } $productsToList = array(); while ($row = $this->_db->Fetch($res)) { // does this product have a variation? if ($row['prodvariationid']) { $variationError = ''; // if the primary category or selling method doesn't support them? if ((empty ($primaryOptions['variations_supported']) || (isset ($secondaryOptions['variations_supported']) && $secondaryOptions['variations_supported'] == 0)) || $template->getSellingMethod() == ISC_ADMIN_EBAY::CHINESE_AUCTION_LISTING) { $variationError = GetLang('EbayListingVariationsNotSupported'); } // does the product have more than 120 combinations (eBay max)? elseif (($totalCombinations = Store_Variations::getCombinationsCount($row['productid'], $row['prodvariationid'])) > 120) { $variationError = GetLang('EbayListingVariationCombinationsExceeded', array('totalCombinations' => $totalCombinations)); } // log error and skip this product if ($variationError) { $error = array( 'prodname' => $row['prodname'], 'time' => time(), 'message' => $variationError, ); $this->_keystore->set($this->_prefix . 'error:' . md5($row['productid'] . uniqid('', true)), ISC_JSON::encode($error)); $errorCount++; continue; } } // add any custom fields and configurable fields to the product ISC_ADMIN_EBAY_LIST_PRODUCTS::addCustomAndConfigurableFields($row); $productsToList[$row['productid']] = $row; } $itemsToAdd = 1; // for chinese auctions if we're selling more than one item, then create multiple items if ($template->getSellingMethod() == ISC_ADMIN_EBAY::CHINESE_AUCTION_LISTING && $template->getQuantityToSell() > 1) { $itemsToAdd = $template->getQuantityToSell(); } $thisBatchSize = $resultCount; $actualProcessed = $thisBatchSize * $itemsToAdd; $actualListed = count($productsToList) * $itemsToAdd; // don't have any products to list for this batch (would be due to disallowed variations)? if (empty($productsToList)) { $this->_keystore->increment($this->_prefix . 'error_count', $errorCount); $this->_keystore->increment($this->_prefix . 'actual_processed', $actualProcessed); $this->_keystore->increment($this->_prefix . 'offset', $thisBatchSize); $this->_logDebug('processed 0 items'); $this->_repeatListing(); return; } $this->_logDebug($actualListed . ' items to list', '<pre>' . var_export($productsToList, true) . '</pre>'); try { // list the items on eBay $results = array(); for ($x = 0; $x < $itemsToAdd; $x++) { $results = array_merge($results, ISC_ADMIN_EBAY_LIST_PRODUCTS::listItems($productsToList, $template)); } foreach ($results as /** @var ISC_ADMIN_EBAY_LIST_ITEM_RESULT */$result) { if (!$result->isValid()) { // log error $error = array( 'prodname' => $result->getProductName(), 'time' => time(), 'message' => implode('<br />', $result->getErrors()), ); $this->_keystore->set($this->_prefix . 'error:' . md5($result->getProductId() . uniqid('', true)), ISC_JSON::encode($error)); $errorCount++; continue; } // valid listing, but has errors if ($result->hasErrors()) { // log warning $error = array( 'prodname' => $result->getProductName(), 'time' => time(), 'message' => implode('<br />', $result->getErrors()), ); $this->_keystore->set($this->_prefix . 'warning:' . md5($result->getProductId() . uniqid('', true)), ISC_JSON::encode($error)); $warningCount++; } // ensure template has correct data set so we can calculate prices for the DB $template->setProductData($result->getProductData()); // add the new item to our local database $insertItem = array( 'product_id' => $result->getProductId(), 'ebay_item_id' => $result->getItemId(), 'title' => $result->getProductName(), 'start_time' => $result->getStartTimeISO(), 'end_time' => $result->getEndTimeISO(), 'datetime_listed' => time(), 'listing_type' => $template->getSellingMethod(), 'listing_status' => 'pending', // this will be updated to 'Active' when we receive ItemListed notification 'current_price_currency' => $template->getCurrencyCode(), 'current_price' => $template->getStartPrice(), 'buyitnow_price' => $template->getBuyItNowPrice(), 'buyitnow_price_currency' => $template->getCurrencyCode(), 'bid_count' => 0, 'quantity_remaining' => $template->getTrueQuantityToSell(), 'site_id' => $template->getSiteId(), ); $dbItemId = $this->_db->InsertQuery('ebay_items', $insertItem); // process the listing fees foreach ($result->getFees() as $fee) { $insertFee = array( 'item_id' => $dbItemId, 'name' => $fee['name'], 'amount' => $fee['fee'], 'currency_code' => $fee['currency'] ); $this->_db->InsertQuery('ebay_item_fees', $insertFee); } $successCount++; } } catch (ISC_EBAY_API_CONNECTION_EXCEPTION $ex) { // connection failed $connectFailCount++; // more than one connection failure? abort the listing if ($connectFailCount > 1) { $this->_abortListing(); } // did the entire request fail? $this->logBatchException($productsToList, $ex); $errorCount += $actualListed; } catch (ISC_EBAY_API_REQUEST_EXCEPTION $ex) { // did the entire request fail? $this->logBatchException($productsToList, $ex); $errorCount += $actualListed; } $this->_keystore->increment($this->_prefix . 'success_count', $successCount); $this->_keystore->increment($this->_prefix . 'warning_count', $warningCount); $this->_keystore->increment($this->_prefix . 'error_count', $errorCount); $this->_keystore->increment($this->_prefix . 'actual_processed', $actualProcessed); $this->_keystore->increment($this->_prefix . 'actual_listed', $actualListed); $this->_keystore->increment($this->_prefix . 'offset', $thisBatchSize); $this->_logDebug('processed ' . $actualListed . ' items'); $this->_repeatListing(); }
/** * 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'); }
/** * Adds calculated rate details to the shipping details * * @param SimpleXMLElement $shippingDetails * @param ISC_ADMIN_EBAY_TEMPLATE $template * @return SimpleXMLElement */ private static function addCalculatedDetails(&$shippingDetails, $template) { $calculatedRate = $shippingDetails->addChild('CalculatedShippingRate'); $calculatedRate->addChild('MeasurementUnit', 'English'); $calculatedRate->addChild('OriginatingPostalCode', $template->getItemLocationZip()); // add dimensions - whole inches only $depth = round(ConvertLength($template->getItemDepth(), 'in')); $length = round(ConvertLength($template->getItemLength(), 'in')); $width = round(ConvertLength($template->getItemWidth(), 'in')); $depthXML = $calculatedRate->addChild('PackageDepth', $depth); $depthXML->addAttribute('measurementSystem', 'English'); $depthXML->addAttribute('unit', 'in'); $lengthXML = $calculatedRate->addChild('PackageLength', $length); $lengthXML->addAttribute('measurementSystem', 'English'); $lengthXML->addAttribute('unit', 'in'); $widthXML = $calculatedRate->addChild('PackageWidth', $width); $widthXML->addAttribute('measurementSystem', 'English'); $widthXML->addAttribute('unit', 'in'); //add weight in pounds and ounces $weightTotal = ConvertWeight($template->getItemWeight(), 'lbs'); $weightMajor = floor($weightTotal); $weightMinor = ConvertWeight($weightTotal - $weightMajor, 'ounces', 'lbs'); if ($weightMinor < 1) { $weightMinor = 1; } $calculatedRate->addChild('WeightMajor', $weightMajor); $calculatedRate->addChild('WeightMinor', $weightMinor); return $calculatedRate; }