holy shit

寺夺喜从天降

输出价格函数(修改)

<?php
// Display Price Retail
// Specials and Tax Included
function zen_get_products_display_price($products_id) {
	global $db, $currencies;

	$free_tag = "";
	$call_tag = "";

	// 0 = normal shopping
	// 1 = Login to shop
	// 2 = Can browse but no prices
	// verify display of prices
	switch (true) {
		case (CUSTOMERS_APPROVAL == '1' and $_SESSION['customer_id'] == ''):
			// customer must be logged in to browse
			return '';
			break;
		case (CUSTOMERS_APPROVAL == '2' and $_SESSION['customer_id'] == ''):
			// customer may browse but no prices
			return TEXT_LOGIN_FOR_PRICE_PRICE;
			break;
		case (CUSTOMERS_APPROVAL == '3' and TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM != ''):
			// customer may browse but no prices
			return TEXT_LOGIN_FOR_PRICE_PRICE_SHOWROOM;
			break;
		case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customer_id'] == ''):
			// customer must be logged in to browse
			return TEXT_AUTHORIZATION_PENDING_PRICE;
			break;
		case ((CUSTOMERS_APPROVAL_AUTHORIZATION != '0' and CUSTOMERS_APPROVAL_AUTHORIZATION != '3') and $_SESSION['customers_authorization'] > '0'):
			// customer must be logged in to browse
			return TEXT_AUTHORIZATION_PENDING_PRICE;
			break;
		default:
			// proceed normally
			break;
	}

	// show case only
	if (STORE_STATUS != '0') {
		if (STORE_STATUS == '1') {
			return '';
		}
	}

	// $new_fields = ', product_is_free, product_is_call, product_is_showroom_only';
	$product_check = $db->Execute("select products_tax_class_id, products_price, products_priced_by_attribute, product_is_free, product_is_call, products_type from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'" . " limit 1");

	// no prices on Document General
	if ($product_check->fields['products_type'] == 3) {
		return '';
	}

	$show_display_price = '';
	$display_normal_price = zen_get_products_base_price($products_id);
	$display_special_price = zen_get_products_special_price($products_id, true);
	$display_sale_price = zen_get_products_special_price($products_id, false);
	$show_sale_discount = '';
	
	if ($display_special_price != 0 or $display_sale_price != 0) {
		if ($display_sale_price) {
			if (SHOW_SALE_DISCOUNT == 1) {
				if ($display_normal_price != 0) {
					$show_discount_amount = number_format(100 - (($display_sale_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS);
				} else {
					$show_discount_amount = '';
				}
				$show_sale_discount = $show_discount_amount;

			} else {
				$show_sale_discount = $currencies->display_price(($display_normal_price - $display_sale_price), zen_get_tax_rate($product_check->fields['products_tax_class_id']));
			}
		} else {
			if (SHOW_SALE_DISCOUNT == 1) {
				$show_sale_discount = number_format(100 - (($display_special_price / $display_normal_price) * 100),SHOW_SALE_DISCOUNT_DECIMALS);
			} else {
				$show_sale_discount = $currencies->display_price(($display_normal_price - $display_special_price), zen_get_tax_rate($product_check->fields['products_tax_class_id'])) ;
			}
		}
	}

	if ($display_special_price) {
		$show_normal_price = $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) ;
		if ($display_sale_price && $display_sale_price != $display_special_price) {
			$show_special_price = $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id']));
			$show_sale_price = $currencies->display_price($display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) ;
		} else {
			$show_special_price = $currencies->display_price($display_special_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) ;
			$show_sale_price = '';
		}
	} else {
		if ($display_sale_price) {
			$show_normal_price = $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) ;
			$show_special_price = '';
			$show_sale_price = $currencies->display_price($display_sale_price, zen_get_tax_rate($product_check->fields['products_tax_class_id']));
		} else {
			$show_normal_price = $currencies->display_price($display_normal_price, zen_get_tax_rate($product_check->fields['products_tax_class_id'])) ;
			$show_special_price = '';
			$show_sale_price = '';
		}
	}
	$output_price = array();
	$output_price['normal'] = $show_normal_price;
	$output_price['special'] = $show_special_price;
	$output_price['sale'] = $show_sale_price;
	$output_price['discount'] = $show_sale_discount;

	// If Free, Show it
	if ($product_check->fields['product_is_free'] == '1') {
		if (OTHER_IMAGE_PRICE_IS_FREE_ON=='0') {
			$free_tag = PRODUCTS_PRICE_IS_FREE_TEXT;
		} else {
			$free_tag = zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_PRICE_IS_FREE, PRODUCTS_PRICE_IS_FREE_TEXT);
		}
	}
	$output_price['is_free'] = $free_tag;
	
	// If Call for Price, Show it
	if ($product_check->fields['product_is_call']) {
		if (PRODUCTS_PRICE_IS_CALL_IMAGE_ON=='0') {
			$call_tag = PRODUCTS_PRICE_IS_CALL_FOR_PRICE_TEXT;
		} else {
			$call_tag = zen_image(DIR_WS_TEMPLATE_IMAGES . OTHER_IMAGE_CALL_FOR_PRICE, PRODUCTS_PRICE_IS_CALL_FOR_PRICE_TEXT);
		}
	}
	$output_price['is_call'] = $call_tag;
	
	return $output_price;

}
?>

posted @ 2011-04-17 16:06  潜水鱼  阅读(449)  评论(0编辑  收藏  举报

holy shit on foot