/**
	 * This function will check against the rules if there is any remaining amount to the cart, in order to get the free shipping.
	 * @param ISC_QUOTE $quote The quote object that used to check the free shipping eligibility
	 * @return boolean Return true if there is we found free shipping eligibility. Otherwise, return false
	 */
	public function checkFreeShippingEligibility(ISC_QUOTE $quote)
	{
		foreach($quote->getItems() as $item) {
			if($quote->getBaseSubTotal() < $this->amount) {
				$remainingAmount = $this->amount - $quote->getBaseSubTotal();
				$productName = $item->getName();
				$placeHolders = array(
					'%%PRODUCT_NAME%%' => $productName,
					'%%REMAINING_QUANTITY%%' => '',
					'%%TOTAL_QUANTITY%%' => $this->amount,
					'%%CART_QUANTITY%%' => $item->getQuantity(),
					'%%REMAINING_AMOUNT%%' => CurrencyConvertFormatPrice($remainingAmount),
					'%%TOTAL_AMOUNT%%' => CurrencyConvertFormatPrice($this->amount),
					'%%CART_AMOUNT%%' => CurrencyConvertFormatPrice($quote->getBaseSubTotal()),
				);
				$this->freeShippingEligibilityData = array(
					'message' => str_replace(array_keys($placeHolders), array_values($placeHolders), $this->freeShippingMessage),
					'location' => $this->freeShippingMessageLocation,
					'name' => $this->getName(),
				);
				return true;
			}
		}
		return false;
	}
	public function applyRule(ISC_QUOTE $quote)
	{
		if (!customerIsSignedIn()) {
			return null;
		}

		$customerId = getClass('ISC_CUSTOMER')->getCustomerId();
		$query = "
			SELECT COUNT(*)
			FROM [|PREFIX|]orders
			WHERE ordcustid='".$customerId."' AND ordstatus > 0 AND deleted = 0
			LIMIT 1
		";
		$orderCount = $GLOBALS['ISC_CLASS_DB']->fetchOne($query);

		// Discount does not apply
		if($orderCount <= $this->orders) {
			return false;
		}

		$items = $quote->getItems();
		$totalDiscount = 0;
		// The discount needs to come off each item, so that tax is also affected.
		foreach($items as $item) {
			$discountAmount = $item->getDiscountedBaseTotal() * ($this->amount / 100);
			$item->addDiscount($this->getDbId(), $discountAmount);
			$totalDiscount += $discountAmount;
		}

		$quote->addDiscount($this->getDbId(), $totalDiscount);
		$this->banners[] = sprintf(getLang($this->getName().'DiscountMessage'), $this->amount);
		return true;
	}
	public function applyRule(ISC_QUOTE $quote)
	{
		if($quote->getBaseSubTotal() < $this->amount) {
			return false;
		}

		$runningTotal = $this->amount_off;
		$items = $quote->getItems();
		foreach ($items as $item) {
			$discountedBase = $item->getDiscountedBaseTotal();
			if($discountedBase - $runningTotal < 0) {
				$item->addDiscount($this->getDbId(), $discountedBase);
				$runningTotal -= $discountedBase;
			}
			else {
				$item->addDiscount($this->getDbId(), $runningTotal);
				$runningTotal -= $runningTotal;
			}

			if($runningTotal <= 0) {
				break;
			}
		}

		$quote->addDiscount($this->getDbId(), $this->amount_off);

		$amountOff = currencyConvertFormatPrice($this->amount_off);
		$amount = currencyConvertFormatPrice($this->amount);
		$this->banners[] = sprintf(getLang($this->getName().'DiscountMessage'), $amountOff, $amount);
		return true;
	}
Ejemplo n.º 4
0
		public function renderMultiShippingTable(ISC_QUOTE $quote)
		{
			if (!$quote->getIsSplitShipping()) {
				return false;
			}

			$unallocatedItems = array();
			$allocatedItems = array();
			foreach ($quote->getItems(PT_PHYSICAL) as $item) {
				if($item->getAddressId() == ISC_QUOTE_ADDRESS::ID_UNALLOCATED) {
					$unallocatedItems[] = $item;
				} else {
					$allocatedItems[] = $item;
				}
			}

			$context = array(
				'allocatedItems' => $allocatedItems,
				'unallocatedItems' => $unallocatedItems,
				'shippingAddresses' => $quote->getShippingAddresses(),
			);

			return $this->template->render('order.form.multishippingtable.tpl', $GLOBALS + $context);
		}
Ejemplo n.º 5
0
	public function haltReset(ISC_QUOTE $quote)
	{
		$items = $quote->getItems();
		foreach($items as $item) {
			if($item->getParentId() || $item->getProductId() != $this->prodids) {
				continue;
			}

			foreach($items as $subItem) {
				if($subItem->getParentId() == $item->getId()) {
					$quote->removeItem($subItem->getId());
				}
			}
		}
	}
Ejemplo n.º 6
0
	/**
	 * This function will check against the rules if there is any related purchase can be made in order to get the free shipping.
	 * @param ISC_QUOTE $quote The quote object that used to check the free shipping eligibility
	 * @return boolean Return true if there is we found free shipping eligibility. Otherwise, return false
	 */
	public function checkFreeShippingEligibility(ISC_QUOTE $quote)
	{
		foreach($quote->getItems() as $item) {
			if($this->prodids == $item->getProductId() && $item->getQuantity() < $this->amount) {
				$remainingQty = $this->amount - $item->getQuantity();
				$productName = $item->getName();
				$placeHolders = array(
					'%%PRODUCT_NAME%%' => $productName,
					'%%REMAINING_QUANTITY%%' => $remainingQty,
					'%%TOTAL_QUANTITY%%' => $this->amount,
					'%%CART_QUANTITY%%' => $item->getQuantity(),
					'%%REMAINING_AMOUNT%%' => '',
					'%%TOTAL_AMOUNT%%' => '',
					'%%CART_AMOUNT%%' => '',
				);
				$this->freeShippingEligibilityData = array(
					'productId' => (int)$this->prodids,
					'message' => str_replace(array_keys($placeHolders), array_values($placeHolders), $this->freeShippingMessage),
					'location' => $this->freeShippingMessageLocation,
					'name' => $this->getName(),
				);
				return true;
			}
		}
		return false;
	}
	public function applyRule(ISC_QUOTE $quote)
	{
		$found = false;
		$items = $quote->getItems();
		$ruleCats = explode(',', $this->catids);

		// The discount needs to come off each item, so that tax is also affected.
		$totalDiscount = 0;
		foreach($items as $item) {
			$apply = false;
			if($item instanceof ISC_QUOTE_ITEM_GIFTCERTIFICATE) {
				continue;
			}

			$categoryIds = $item->getCategoryIds();
			foreach($ruleCats as $categoryId) {
				if(!in_array($categoryId, $categoryIds) && $categoryId != 0) {
					continue;
				}

				$apply = true;
				$found[] = $categoryId;
			}

			if(!$apply) {
				continue;
			}

			$discountAmount = $item->getBaseTotal() * ($this->amount / 100);
			$discountAmount = round($discountAmount, getConfig('DecimalPlaces'));
			if($item->getBaseTotal() - $discountAmount < 0) {
				$discountAmount = 0;
			}

			$item->addDiscount($this->getDbId(), $discountAmount);
			$totalDiscount += $discountAmount;
		}

		if (!empty($found)) {

			$quote->addDiscount($this->getDbId(), $totalDiscount);

			$catname = '';
			$catids = implode(',', $found);

			$query = "
				SELECT catname
				FROM [|PREFIX|]categories
				WHERE categoryid IN ($catids)
			";
			$result = $GLOBALS['ISC_CLASS_DB']->Query($query);
			while($var = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				$catname[] = $var['catname'];
			}
			if (isset($catname{1})) {
				$this->banners[] = sprintf(GetLang($this->getName().'DiscountMessagePlural'), $this->amount, implode(' and ',$catname));
			} else {
				$this->banners[] = sprintf(GetLang($this->getName().'DiscountMessage'), $this->amount, implode(' and ',$catname));

			}
			return true;
		}

		return false;
	}
	public function applyRule(ISC_QUOTE $quote)
	{
		$customerId = getClass('ISC_CUSTOMER')->getCustomerId();
		$query = "
			SELECT COUNT(*)
			FROM [|PREFIX|]orders
			WHERE ordcustid='".$customerId."' AND ordstatus > 0 AND deleted = 0
			LIMIT 1
		";
		$orderCount = $GLOBALS['ISC_CLASS_DB']->fetchOne($query);

		// Discount does not apply
		if($orderCount <= $this->orders) {
			return false;
		}

		$runningTotal = $this->amount;
		$appliedAmount = 0;
		$items = $quote->getItems();
		foreach ($items as $item) {
			$discountedBase = $item->getDiscountedBaseTotal();
			if($discountedBase - $runningTotal < 0) {
				$item->addDiscount($this->getDbId(), $discountedBase);
				$appliedAmount += $discountedBase;
				$runningTotal -= $discountedBase;
			}
			else {
				$item->addDiscount($this->getDbId(), $runningTotal);
				$appliedAmount += $runningTotal;
				$runningTotal -= $runningTotal;
			}

			if($runningTotal <= 0) {
				break;
			}
		}

		$quote->addDiscount($this->getDbId(), $appliedAmount);

		$amount = currencyConvertFormatPrice($appliedAmount);
		$this->banners[] = sprintf(getLang($this->getName().'DiscountMessage'), $amount);
		return true;
	}