public function GetProductVariationCombinationJavascript() { if (empty($this->_prodvariationcombinations)) { return ''; } $script = "<script type=\"text/javascript\">\n"; $script .= " var VariationList = new Array();\n"; foreach ($this->_prodvariationcombinations as $variation) { $variationPrice = CurrencyConvertFormatPrice(CalcProductVariationPrice($this->_prodcalculatedprice, $variation['vcpricediff'], $variation['vcprice'], $this->_product)); $youSave = $this->_prodretailprice - CalcProductVariationPrice($this->_prodcalculatedprice, $variation['vcpricediff'], $variation['vcprice'], $this->_product); $variationSaveAmount = ''; if ($youSave > 0) { $variationSaveAmount = CurrencyConvertFormatPrice($youSave); } $variationWeight = FormatWeight(CalcProductVariationWeight($this->_prodweight, $variation['vcweightdiff'], $variation['vcweight']), true); if ($variation['vcthumb'] != '') { $thumb = $GLOBALS['ShopPath'] . "/" . GetConfig('ImageDirectory') . "/" . $variation['vcthumb']; } else { $thumb = ''; } if ($variation['vcimage'] != '') { $image = $GLOBALS['ShopPath'] . '/' . GetConfig('ImageDirectory') . '/' . $variation['vcimage']; } else { $image = ''; } $ids = explode(",", $variation['vcoptionids']); $optionList = array(); foreach ($ids as $id) { $key = $this->_prodvariationslookup[$id]; $optionList[$key] = $id; } ksort($optionList); $optionList = implode(",", $optionList); $script .= " VariationList[" . $variation['combinationid'] . "] = {"; $script .= " combination: '" . $optionList . "', "; $script .= " saveAmount: '" . $variationSaveAmount . "', "; $script .= " price: '" . $variationPrice . "', "; $script .= " sku: '" . isc_html_escape($variation['vcsku']) . "', "; $script .= " weight: '" . $variationWeight . "', "; $script .= " thumb: '" . $thumb . "', "; $script .= " image: '" . $image . "', "; // Tracking inventory on a product variation level if ($this->_prodinvtrack == 2) { if (GetConfig('ShowInventory') == 1) { $script .= "stock: '" . $variation['vcstock'] . "', "; } if ($variation['vcstock'] <= 0) { $script .= " instock: false"; } else { $script .= " instock: true"; } } else { $script .= " instock: true"; } $script .= "};\n"; } $script .= "</script>"; return $script; }
public function Action_GetProduct() { if(empty($this->router->request->details->productId)) { $this->BadRequest('The details->productId node is missing'); } $image = new ISC_PRODUCT_IMAGE(); // autoload helper so we can use exceptions defined in the product image class file unset($image); $productId = (int)$this->router->request->details->productId; $productClass = new ISC_PRODUCT($productId); $product = $productClass->_product; // stuff that comes directly from the database may be incomplete -- use the image library to make sure try { if (!$product['imageid']) { // no image present in data so throw an exception just to force the removal of data below in the catch{} block throw new ISC_PRODUCT_IMAGE_EXCEPTION(); } $image = new ISC_PRODUCT_IMAGE(); $image->populateFromDatabaseRow($product); // call the image library to make sure resized images are present and then add full urls so they're useful for remote users $product['imagefiletiny'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true, true, false); $product['imagefilethumb'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, true, false); $product['imagefilestd'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, true, false); $product['imagefilezoom'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, true, false); // call the image library to make sure resized images are present and the sizes are correct $product['imagefiletinysize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY)); $product['imagefilethumbsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL)); $product['imagefilestdsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_STANDARD)); $product['imagefilezoomsize'] = implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_ZOOM)); } catch (Exception $exception) { // some sort of problem when dealing with product images - remove image info from the response unset( $product['imagefiletiny'], $product['imagefilethumb'], $product['imagefilestd'], $product['imagefilezoom'], $product['imagefiletinysize'], $product['imagefilethumbsize'], $product['imagefilestdsize'], $product['imagefilezoomsize'], $product['imagedesc'], $product['imagedateadded'] ); } // direct data feed also includes some fields that are irrelevant or unwanted unset( $product['imagefile'], // don't provide a link to the non-water-marked image $product['imageprodid'], $product['imageprodhash'], $product['imageisthumb'], $product['imagesort'] ); if(empty($product)) { return array(); } $product['prodlink'] = ProdLink($product['prodname']); // Fetch any images for the product $images = new ISC_PRODUCT_IMAGE_ITERATOR(ISC_PRODUCT_IMAGE::generateGetProductImagesFromDatabaseSql((int)$productId)); foreach ($images as $image) { /** @var $image ISC_PRODUCT_IMAGE */ $imageisthumb = 0; if ($image->getIsThumbnail()) { $imageisthumb = 1; } try { $product['images']['item'][] = array( 'imageid' => $image->getProductImageId(), 'imagefiletiny' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_TINY, true, true, false), 'imagefilethumb' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, true, false), 'imagefilestd' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, true, false), 'imagefilezoom' => $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, true, false), 'imagefiletinysize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_TINY)), 'imagefilethumbsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL)), 'imagefilestdsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_STANDARD)), 'imagefilezoomsize' => implode('x', $image->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_ZOOM)), 'imageisthumb' => $imageisthumb, 'imagesort' => $image->getSort(), 'imagedesc' => $image->getDescription(), 'imagedateadded' => $image->getDateAdded(), ); } catch (Exception $exception) { // skip this image and bring down the count of product images obtained from ISC_PRODUCT $product['numimages']--; } } // Fetch the categories this product belongs to $trailCategories = array(); $crumbList = array(); $query = " SELECT c.categoryid, c.catparentlist FROM [|PREFIX|]categoryassociations ca JOIN [|PREFIX|]categories c ON (c.categoryid=ca.categoryid) WHERE ca.productId='".(int)$productId."' "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { if ($row['catparentlist'] == '') { $row['catparentlist'] = $row['categoryid']; } $cats = explode(",", $row['catparentlist']); $trailCategories = array_merge($trailCategories, $cats); $crumbList[$row['categoryid']] = $row['catparentlist']; } $trailCategories = implode(",", array_unique($trailCategories)); $categories = array(); if ($trailCategories != '') { // Now load the names for the parent categories from the database $query = " SELECT categoryid, catname FROM [|PREFIX|]categories WHERE categoryid IN (".$trailCategories.") "; $result = $GLOBALS['ISC_CLASS_DB']->Query($query); while ($row = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) { $categories[$row['categoryid']] = $row['catname']; } } // Now we have all of the information we need to build the trails, lets actually build them foreach ($crumbList as $productcatid => $trail) { $cats = explode(',', $trail); $catName = ''; $catLink = CatLink($productcatid, $categories[$productcatid]); foreach ($cats as $categoryid) { if(isset($categories[$categoryid])) { if($catName) { $catName .= ' » '; } $catName .= $categories[$categoryid]; } } $product['categories']['item'][] = array( 'name' => $catName, 'link' => $catLink, 'id' => $productcatid ); } if($product['prodvariationid'] > 0) { if ($product['prodsaleprice'] != 0) { $variationBasePrice = $product['prodsaleprice']; } else { $variationBasePrice = $product['prodprice']; } $vop = $productClass->_prodvariationoptions; $vval = $productClass->_prodvariationvalues; foreach($productClass->_prodvariationcombinations as $variation) { $variationPrice = CurrencyConvertFormatPrice(CalcProductVariationPrice($variationBasePrice, $variation['vcpricediff'], $variation['vcprice'], $product)); $variationWeight = FormatWeight(CalcProductVariationWeight($product['prodweight'], $variation['vcweightdiff'], $variation['vcweight']), true); $variationName = array(); $options = explode(',', $variation['vcoptionids']); foreach($options as $k => $optionId) { $label = $vop[$k]; $variationName[] = $label.': '.$vval[$label][$optionId]; } $variationName = implode(', ', $variationName); $variationRow = array( 'name' => $variationName, 'id' => $variation['combinationid'], 'price' => $variationPrice, 'sku' => $variation['vcsku'], 'weight' => $variationWeight, ); if($product['prodinvtrack'] == 2) { $variationRow['stock'] = $variation['vcstock']; } if ($variation['vcimage']) { try { $image = new ISC_PRODUCT_IMAGE; $image->setSourceFilePath($variation['vcimage']); if($variation['vcimagethumb']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, $variation['vcimagethumb']); $variationRow['thumb'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true, false); } if($variation['vcimagestd']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, $variation['vcimagestd']); $variationRow['standard'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, false); } if($variation['vcimagezoom']) { $image->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, $variation['vcimagezoom']); $variationRow['image'] = $image->getResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, false); } } catch (Exception $exception) { // nothing } } $product['variations']['item'][] = $variationRow; } } return $product; }
public function buildXML() { if (isc_strtolower($this->spool["service"]) == "edit" && is_array($this->spoolReferenceData)) { $this->writeEscapedElement("ListID", $this->spoolReferenceData["ListID"]); $this->writeEscapedElement("EditSequence", $this->spoolReferenceData["EditSequence"]); } $this->buildProductVariationNameNode($this->spoolNodeData["prodname"], $this->spoolNodeData["combinationid"]); $this->writeEscapedElement("IsActive", "true"); /** * Set the product variation parent. Only do this for adding (want to edit the least amount as possible) */ if (isc_strtolower($this->spool["service"]) == "add") { $productTypeListId = $this->accounting->getProductParentTypeListId(true); if (!$productTypeListId || trim($productTypeListId) == '') { throw new QBException("Unable to find product parent type reference for product variation in productvariation", $this->spool); } $this->xmlWriter->startElement("ParentRef"); $this->writeEscapedElement("ListID", $productTypeListId); $this->xmlWriter->endElement(); } if ($this->compareClientVersion("7.0") && isset($this->spoolNodeData["vcsku"]) && $this->spoolNodeData["vcsku"] !== "") { $this->writeEscapedElement("ManufacturerPartNumber", $this->spoolNodeData["vcsku"]); } /** * OK, different tag names for different versions for different countries. Good times, good times */ if ($this->compareClientCountry("uk") || $this->compareClientCountry("ca")) { if ($this->compareClientVersion("3.0")) { $this->xmlWriter->startElement("TaxCodeForSaleRef"); } else { $this->xmlWriter->startElement("TaxCodeRef"); } } else { $this->xmlWriter->startElement("SalesTaxCodeRef"); } $this->writeEscapedElement("FullName", "NON"); $this->xmlWriter->endElement(); $this->writeEscapedElement("SalesDesc", isc_substr($this->spoolNodeData["prodvariationname"], 0, 4095)); $prodPrice = CalcProductVariationPrice($this->spoolNodeData["prodprice"], $this->spoolNodeData["vcpricediff"], $this->spoolNodeData["vcprice"]); $this->writeEscapedElement("SalesPrice", number_format($prodPrice, 2, ".", "")); /** * We can only set this for the add process as the mod process is only available in versions 7.0 and above */ if (isc_strtolower($this->spool["service"]) == "add" || $this->compareClientVersion("7.0")) { $incomeAccountListId = $this->accounting->getAccountListId("income"); if (trim($incomeAccountListId) == '') { throw new QBException("Cannot find the income account ListID for product variation ID: " . $this->spoolNodeData["combinationid"], $this->spool); } $this->xmlWriter->startElement("IncomeAccountRef"); $this->writeEscapedElement("ListID", $incomeAccountListId); $this->xmlWriter->endElement(); } if (isset($this->spoolNodeData["prodcostprice"]) && $this->spoolNodeData["prodcostprice"] > 0) { $this->writeEscapedElement("PurchaseDesc", isc_substr($this->spoolNodeData["prodvariationname"], 0, 4095)); $this->writeEscapedElement("PurchaseCost", number_format($this->spoolNodeData["prodcostprice"], 2, ".", "")); } $cogsAccountListId = $this->accounting->getAccountListId("costofgoodssold"); if (trim($cogsAccountListId) == '') { throw new QBException("Cannot find the cogs account ListID for product variation ID: " . $this->spoolNodeData["combinationid"], $this->spool); } $this->xmlWriter->startElement("COGSAccountRef"); $this->writeEscapedElement("ListID", $cogsAccountListId); $this->xmlWriter->endElement(); $fixedAccountListId = $this->accounting->getAccountListId("fixedasset"); if (trim($fixedAccountListId) == '') { throw new QBException("Cannot find the fixed account ListID for product ID: " . $this->spoolNodeData["combinationid"], $this->spool); } $this->xmlWriter->startElement("AssetAccountRef"); $this->writeEscapedElement("ListID", $fixedAccountListId); $this->xmlWriter->endElement(); /** * Only do this is we are a new product OR if we are handling the inventory levels */ if (isc_strtolower($this->spool["service"]) == "add" || $this->accounting->getValue("invlevels") == ACCOUNTING_QUICKBOOKS_TYPE_SHOPPINGCART) { $this->writeEscapedElement("ReorderPoint", (int)$this->spoolNodeData["vclowstock"]); } if ($this->compareClientCountry("uk") && $this->compareClientVersion("2.0")) { if (GetConfig("PricesIncludeTax")) { $this->writeEscapedElement("AmountIncludesVAT", "1"); } else { $this->writeEscapedElement("AmountIncludesVAT", "0"); } } return $this->buildOutput(); }
/** * 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'); } }