Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Show the text if value = 1


shmekera

Recommended Posts

Hi!

 

I added a new column in customers table - customers_wholesale. The default value is "0" (for each new customer).

I want to put a code into products_info.php - If the logged user has "customers_wholesale = 1" to view the price.

Please, help me with the code..

 

I tried this but its not working:

 

<?php
}

if (tep_not_null($customers['customers_wholesale'])) {
?>

													  <tr>
														<td align="center" class="pageHeading"><center>Wholesale Price: <?php echo $products_wholesale; ?></center><br></td>
													  </tr>
<?php
} else {
?>

 

Sorry for the bad English.

Link to comment
Share on other sites

Here is a start, you will have to tweak it:

 

in includes/classes/currencies.php

 

change

	function display_price($products_price, $products_tax, $quantity = 1) {
return $this->format($this->calculate_price($products_price, $products_tax, $quantity));
}

 

to

	function display_price($products_price, $products_tax, $quantity = 1) {
$let_them_see_prices = 0;
$get_id = array();
$get_id_query = tep_db_query("select customers_wholesale from customers where customers_id = $customer_id");
while ($their_id = tep_db_fetch_array($get_id_query)) {
if ($their_id['customers_wholesale']== 1) {$let_them_see_prices = 1;}
}

if( (tep_session_is_registered('customer_id')) && ($let_them_see_prices == 1) ) {
return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);	
} else {
return '$ for Dealers Only';
}

 

this was taken from:

http://addons.oscommerce.com/info/601

Link to comment
Share on other sites

Thank you very much!! I think it will works perfect but I have little error:

Parse error: parse error, expecting `T_OLD_FUNCTION' or `T_FUNCTION' or `T_VAR' or `'}'' in d:\web\www\web\shop\includes\classes\currencies.php on line 84

 

But on line 84 is the end of the php "?>"

I can't understand the error very well.. The } tags are fine.. any ideas?

Link to comment
Share on other sites

Here is currencies.php:

 

<?php
/*
 $Id: currencies.php,v 1.16 2003/06/05 23:16:46 hpdl Exp $

E-Commerce Solutions

 Copyright (c) 2005 www.flash-template-design.com

 Released under the GNU General Public License
*/

////
// Class to handle currencies
// TABLES: currencies
 class currencies {
var $currencies;

// class constructor
function currencies() {
  $this->currencies = array();
  $currencies_query = tep_db_query("select code, title, symbol_left, symbol_right, decimal_point, thousands_point, decimal_places, value from " . TABLE_CURRENCIES);
  while ($currencies = tep_db_fetch_array($currencies_query)) {
	$this->currencies[$currencies['code']] = array('title' => $currencies['title'],
												   'symbol_left' => $currencies['symbol_left'],
												   'symbol_right' => $currencies['symbol_right'],
												   'decimal_point' => $currencies['decimal_point'],
												   'thousands_point' => $currencies['thousands_point'],
												   'decimal_places' => $currencies['decimal_places'],
												   'value' => $currencies['value']);
  }
}

// class methods
function format($number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') {
  global $currency;

  if (empty($currency_type)) $currency_type = $currency;

  if ($calculate_currency_value == true) {
	$rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
	$format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
// if the selected currency is in the european euro-conversion and the default currency is euro,
// the currency will displayed in the national currency and euro currency
	if ( (DEFAULT_CURRENCY == 'EUR') && ($currency_type == 'DEM' || $currency_type == 'BEF' || $currency_type == 'LUF' || $currency_type == 'ESP' || $currency_type == 'FRF' || $currency_type == 'IEP' || $currency_type == 'ITL' || $currency_type == 'NLG' || $currency_type == 'ATS' || $currency_type == 'PTE' || $currency_type == 'FIM' || $currency_type == 'GRD') ) {
	  $format_string .= ' <small>[' . $this->format($number, true, 'EUR') . ']</small>';
	}
  } else {
	$format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number, $this->currencies[$currency_type]['decimal_places']), $this->currencies[$currency_type]['decimal_places'], $this->currencies[$currency_type]['decimal_point'], $this->currencies[$currency_type]['thousands_point']) . $this->currencies[$currency_type]['symbol_right'];
  }

  return $format_string;
}

function is_set($code) {
  if (isset($this->currencies[$code]) && tep_not_null($this->currencies[$code])) {
	return true;
  } else {
	return false;
  }
}

function get_value($code) {
  return $this->currencies[$code]['value'];
}

function get_decimal_places($code) {
  return $this->currencies[$code]['decimal_places'];
}

function display_price($products_price, $products_tax, $quantity = 1) {
  return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
}
 }
?>

Link to comment
Share on other sites

change the function display_price to:

 

function display_price($products_price, $products_tax, $quantity = 1)
{

$let_them_see_prices = 0;
$get_id = array();
$get_id_query = tep_db_query("select customers_wholesale from customers where customers_id = $customer_id");

  while ($their_id = tep_db_fetch_array($get_id_query))
  {
   if ($their_id['customers_wholesale']== 1) {$let_them_see_prices = 1;}
  }

	if( (tep_session_is_registered('customer_id')) && ($let_them_see_prices == 1) )
	{
	return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);	
	} else {
	return '$ for Dealers Only';
	}
}

 

the above change I posted above was missing the closing '}'

Link to comment
Share on other sites

I tried to put } before few days and I get this error:

1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1

select customers_wholesale from customers where customers_id =

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...