Exemplo n.º 1
0
	/**
	* Removes addresses from the database for order $orderId which are not in the ISC_QUOTE instance $quote, will also delete info associated with that address (shipping and products)
	*
	* @param int $orderId
	* @param ISC_QUOTE $quote
	* @return bool false on error otherwise true
	*/
	public function deleteUnusedOrderAddresses($orderId, ISC_QUOTE $quote)
	{
		$orderId = (int)$orderId;
		$addresses = $this->db->Query("SELECT `id` FROM [|PREFIX|]order_addresses WHERE order_id = " . $orderId);
		if (!$addresses) {
			return false;
		}

		while ($address = $this->db->Fetch($addresses)) {
			$addressId = (int)$address['id'];
			$quoteAddress = $quote->getAddressById($addressId);
			if ($quoteAddress) {
				continue;
			}

			if (!$this->deleteOrderAddress($orderId, $addressId)) {
				return false;
			}
		}

		return true;
	}