Пример #1
0
	/**
	 * Set general pricing details for the product.
	 */
	private function SetPricingDetails()
	{
		$product = $this->productClass->getProduct();

		$GLOBALS['PriceLabel'] = GetLang('Price');

		if($this->productClass->GetProductCallForPricingLabel()) {
			$GLOBALS['ProductPrice'] = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseGL($this->productClass->GetProductCallForPricingLabel());
		}
		// If prices are hidden, then we don't need to go any further
		else if($this->productClass->ArePricesHidden()) {
			$GLOBALS['HidePrice'] = "display: none;";
			$GLOBALS['HideRRP'] = 'none';
			$GLOBALS['ProductPrice'] = '';
			return;
		}
		else {
			$options = array('strikeRetail' => false);
			$GLOBALS['ProductPrice'] = formatProductDetailsPrice($product, $options);
		}

		// Determine if we need to show the RRP for this product or not
		// by comparing the price of the product including any taxes if
		// there are any
		$GLOBALS['HideRRP'] = "none";
		$productPrice = $product['prodcalculatedprice'];
		$retailPrice = $product['prodretailprice'];
		if($retailPrice) {
			// Get the tax display format
			$displayFormat = getConfig('taxDefaultTaxDisplayProducts');
			$options['displayInclusive'] = $displayFormat;

			// Convert to the browsing currency, and apply group discounts
			$productPrice = formatProductPrice($product, $productPrice, array(
				'localeFormat' => false, 'displayInclusive' => $displayFormat
			));
			$retailPrice = formatProductPrice($product, $retailPrice, array(
				'localeFormat' => false, 'displayInclusive' => $displayFormat
			));

			if($productPrice < $retailPrice) {
				$GLOBALS['HideRRP'] = '';

				// Showing call for pricing, so just show the RRP and that's all
				if($this->productClass->GetProductCallForPricingLabel()) {
					$GLOBALS['RetailPrice'] = CurrencyConvertFormatPrice($retailPrice);
				}
				else {
					// ISC-1057: do not apply customer discount to RRP in this case
					$retailPrice = formatProductPrice($product, $product['prodretailprice'], array(
						'localeFormat' => false,
						'displayInclusive' => $displayFormat,
						'customerGroup' => 0,
					));
					$GLOBALS['RetailPrice'] = '<strike>' . formatPrice($retailPrice) . '</strike>';
					$GLOBALS['PriceLabel'] = GetLang('YourPrice');
					$savings = $retailPrice - $productPrice;
					$string = sprintf(getLang('YouSave'), '<span class="YouSaveAmount">'.formatPrice($savings).'</span>');
					$GLOBALS['YouSave'] = '<span class="YouSave">'.$string.'</span>';
				}
			}
		}
	}
Пример #2
0
		/**
		* Gets an array of formatted details for a specific combination row such as pricing, weight, images
		*
		* @param array Database row of combination information
		* @param int The customer group to use to determine the final product price (used when getting variation details from back end quote system)
		* @return array The formatted combination details
		*/
		public function GetCombinationDetails($combination, $customerGroupId = null)
		{
			$thumb = '';
			$image = '';

			$priceOptions = array(
				'variationModifier'		=> $combination['vcpricediff'],
				'variationAdjustment'	=> $combination['vcprice'],
			);

			if (!is_null($customerGroupId)) {
				$priceOptions['customerGroup'] = $customerGroupId;
			}

			if($this->GetProductCallForPricingLabel()) {
				$variationPrice = $GLOBALS['ISC_CLASS_TEMPLATE']->ParseGL($this->GetProductCallForPricingLabel());
			}
			else {
				$variationPrice = formatProductDetailsPrice($this->_product, $priceOptions);
			}

			$calculatedPrice = calculateFinalProductPrice($this->_product, $this->_prodcalculatedprice, $priceOptions);
			$calculatedPrice = getClass('ISC_TAX')->getPrice(
				$calculatedPrice,
				$this->_product['tax_class_id'],
				getConfig('taxDefaultTaxDisplayProducts')
			);

			$variationSaveAmount = '';
			if($this->_prodretailprice > 0) {
				$rrp = calculateFinalProductPrice($this->_product, $this->_prodretailprice, $priceOptions);
				$rrp = getClass('ISC_TAX')->getPrice(
					$rrp,
					$this->_product['tax_class_id'],
					getConfig('taxDefaultTaxDisplayProducts')
				);

				$youSave = $rrp - $calculatedPrice;
				if($youSave > 0) {
					$variationSaveAmount = CurrencyConvertFormatPrice($youSave);
				}
			}

			$variationWeight = FormatWeight(CalcProductVariationWeight($this->_prodweight, $combination['vcweightdiff'], $combination['vcweight']), true);

			// use the product image class for automatic resizing
			$productImage = new ISC_PRODUCT_IMAGE;
			if ($combination['vcimage']) {
				$productImage->setSourceFilePath($combination['vcimage']);

				if ($combination['vcimagestd']) {
					$productImage->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_STANDARD, $combination['vcimagestd']);
					$thumb = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_STANDARD, true, false);
				}

				if ($combination['vcimagezoom']) {
					//check if zoom image is large enough for image zoomer
					try {
						$productImage->setResizedFilePath(ISC_PRODUCT_IMAGE_SIZE_ZOOM, $combination['vcimagezoom']);
						list($zoomWidth, $zoomHeight) = $productImage->getResizedFileDimensions(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, false);
						if ($zoomWidth >= ISC_PRODUCT_IMAGE_MIN_ZOOM_WIDTH || $zoomHeight >= ISC_PRODUCT_IMAGE_MIN_ZOOM_HEIGHT) {
							$image = $productImage->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true, false);
						}
					} catch (Exception $exception) {
						// do nothing, will result in returning blank string, which is fine
					}
				}
			}

			// Tracking inventory on a product variation level
			if($this->_prodinvtrack == 2) {
				$stock = $combination['vcstock'];
			}
			else {
				$stock = $this->_prodcurrentinv;
			}

			if($stock <= 0 && $this->_prodinvtrack != 0) {
				$instock = false;
			}
			else {
				$instock = true;
			}

			$return = array(
				'combinationid'			=> $combination['combinationid'],
				'saveAmount'			=> $variationSaveAmount,
				'price'					=> $variationPrice,
				'unformattedPrice'      => formatPrice($calculatedPrice, false, false),
				'sku'					=> $combination['vcsku'],
				'weight'				=> $variationWeight,
				'thumb'					=> $thumb,
				'image'					=> $image,
				'instock'				=> $instock
			);

			if (GetConfig('ShowInventory') == 1 && (!$this->IsPreOrder() || GetConfig('ShowPreOrderInventory') == 1)) {
				$return['stock'] = $stock;
			}
			return $return;
		}