Exemplo n.º 1
0
/**
 * Return a formatted price for a product for display on product detail pages.
 * Detail pages are defined as those product pages which contain the primary
 * details for a product.
 *
 * @see formatProductPrice
 * @param array $product Array containing the product to format the price for.
 * @param array $options Array of options, passed to formatProductPrice
 * @return string Generated HTML to display the price for the product.
 */
function formatProductDetailsPrice($product, array $options = array())
{
	$displayFormat = getConfig('taxDefaultTaxDisplayProducts');
	$options['displayInclusive'] = $displayFormat;

	if($displayFormat != TAX_PRICES_DISPLAY_BOTH) {
		return formatProductPrice($product, $product['prodcalculatedprice'], $options);
	}

	$options['displayInclusive'] = TAX_PRICES_DISPLAY_INCLUSIVE;
	$priceIncTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);

	$options['displayInclusive'] = TAX_PRICES_DISPLAY_EXCLUSIVE;
	$priceExTax = formatProductPrice($product, $product['prodcalculatedprice'], $options);

	$output = '<span class="ProductDetailsPriceIncTax">';
	$output .= $priceIncTax;
	$output .= getLang('ProductDetailsPriceIncTaxLabel', array(
		'label' => getConfig('taxLabel')
	));
	$output .= '</span> ';
	$output .= '<span class="ProductDetailsPriceExTax">';
	$output .= $priceExTax;
	$output .= getLang('ProductDetailsPriceExTaxLabel', array(
		'label' => getConfig('taxLabel')
	));
	$output  .= '</span>';
	return $output;
}
Exemplo n.º 2
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>';
				}
			}
		}
	}
Exemplo n.º 3
0
		private function _BuildProductFeed($feedTitle, $feedDescription, $feedId, $sortField, $sortOrder, $searchTerms=array())
		{
			$this->_SetFeedDetails();

			$feed = new ISC_FEED_GENERATOR($feedId, $this->_type, (int)GetConfig('RSSCacheTime')*60);

			$channel = array(
				"title" => $feedTitle,
				"description" => $feedDescription,
				"link" => $GLOBALS['ShopPath'],
				'namespaces' => array(
					'isc' => array(
						//'http://dtd.interspire.com/rss/isc-1.0.dtd',
				        '',
						array(
							'store_title' => getConfig('StoreName')
						)
					)
				)
			);
			$feed->SetChannel($channel);

			// The magical Unreal Shopping Cart RSS feeds are actually just custom searches so pipe it off to our search function
			$searchterms = BuildProductSearchTerms($searchTerms);

			$searchQueries = BuildProductSearchQuery($searchterms, '', $sortField, $sortOrder);

			// Run the query
			$searchQueries['query'] .= $GLOBALS['ISC_CLASS_DB']->AddLimit(0, (int)GetConfig('RSSItemsLimit'));
			$result = $GLOBALS['ISC_CLASS_DB']->Query($searchQueries['query']);

			while($product = $GLOBALS['ISC_CLASS_DB']->Fetch($result)) {
				if(isc_strlen($product['proddesc']) > 300) {
					$product['proddesc'] = isc_substr($product['proddesc'], 0, 298)."..";
				}

				$item = array(
					'title' => $product['prodname'],
					'date' => $product['proddateadded'],
					'link' => prodLink($product['prodname']),
					'namespaces' => array(
						'isc' => array(
							'description' => $product['proddesc'],
							'productid' => $product['productid'],
						)
					)
				);

				if($product['imagefile']) {
					$thumb = ImageThumb($product, ProdLink($product['prodname']));
					$product['proddesc'] = sprintf("<div style='float: right; padding: 10px;'>%s</div>%s", $thumb, $product['proddesc']);

					$image = new ISC_PRODUCT_IMAGE;
					$image->populateFromDatabaseRow($product);

					try {
						$item['namespaces']['isc']['thumb'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_THUMBNAIL, true);
					} catch (Exception $exception) { }

					try {
						$item['namespaces']['isc']['image'] = $image->getResizedUrl(ISC_PRODUCT_IMAGE_SIZE_ZOOM, true);
					} catch (Exception $exception) { }

					unset ($image);
				}

				// Determine the price of this product
				$price = '';
				if (GetConfig('ShowProductPrice') && !$product['prodhideprice']) {
					$calcPrice = $product['prodcalculatedprice'];
					$plainPrice = formatProductPrice($product, $calcPrice, array(
						'strikeRetail' => false,
						'displayInclusive' => getConfig('taxDefaultTaxDisplayCatalog')
					));

					if($plainPrice) {
						$item['namespaces']['isc']['price'] = $plainPrice;
						$price = '<strong>'.getLang('Price').': '.$plainPrice.'</strong>';
					}
				}

				if(GetConfig('ShowProductRating')) {
					$ratingImage = $GLOBALS['IMG_PATH'].'/IcoRating'.(int)$product['prodavgrating'].'.gif';
					$item['namespaces']['isc']['rating'] = (int)$product['prodavgrating'];
					$item['namespaces']['isc']['rating_image'] = $ratingImage;

					$ratingImage = '<img src="'.$ratingImage.'" alt="" />';
				}
				else {
					$ratingImage = '';
				}

				$product['proddesc'] .= '<p>'.$price.' '.$ratingImage.'</p>';

				$item['description'] = $product['proddesc'];
				$feed->AddItem($item);
			}

			// Send the feed to the browser
			$feed->OutputFeed();

		}