Esempio n. 1
0
	/**
	* 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;
	}