示例#1
0
	/**
	 * Generates the suffix for shipping method names based on the
	 * quote's current shipping address. Eg 'USPS Express (CA)'
	 */
	private function getShippingMethodSuffix()
	{
		$zone = getShippingZoneById($this->quote->getShippingAddress()
			->getShippingAddressZone());

		if($zone['zoneid'] == 1) {
			return null;
		}

		return ' ('.$zone['zonename'].')';
	}
	public function allowsFreeShipping()
	{
		// If the quote has a free shipping option, then so does this address
		if ($this->getQuote()->getHasFreeShipping()) {
			return true;
		}

		$items = $this->getItems();
		$freeShippingProducts = 0;

		foreach ($items as $item) {
			if ($item->hasFreeShipping()) {
				++$freeShippingProducts;
			}
		}

		if ($freeShippingProducts == count($items)) {
			return true;
		}

		$shippingZoneId = $this->getShippingAddressZone();
		if (!$shippingZoneId) {
			return false;
		}

		$shippingZone = getShippingZoneById($shippingZoneId);
		if ($shippingZone['zonefreeshipping']) {
			$subTotal = $this->getQuote()->getDiscountedBaseSubTotal();
			if ($subTotal >= $shippingZone['zonefreeshippingtotal']) {
				return true;
			}
		}

		return false;
	}