Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Changing the currencies...


.sEBAs.

Recommended Posts

hello, my name is Sebasti?n...

 

I have a problema, and it's the currencies....

Can the currencies note differencies between one product front another....??

Becouse, i have one product that it must have a different currencies without changing the type of money :P

 

Please help me....

And sorry about my english... :-"

 

bye..

 

Saludos.! :rolleyes:

Link to comment
Share on other sites

hello, my name is Sebasti?n...

 

I have a problema, and it's the currencies....

Can the currencies note differencies between one product front another....??

Becouse, i have one product that it must have a different currencies without changing the type of money :P

 

Please help me....

And sorry about my english... :-"

 

bye..

 

Saludos.! :rolleyes:

 

You mean that you want currencies tied to products so you can have one product shown in dollars and another product in euro's ?! As far as I know there is nothing special made for at this moment. As you have probably already seen there is a default currency, which applies to all products, and you can add some more currencies which also apply to all products when a customer switches to that currency.

If you start working on a contribution like this realize that you will have to work out something for consistency during the checkout process and sending the final payment to a payment processor !

Link to comment
Share on other sites

I have already done something(on currencies.php), but the problem is when the subtotal cames in.... :P

 

// 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, value_kit 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'],
												   'value_kit' => $currencies['value_kit']);
  }
}

// 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) {
	if ($quantity == 0) {
	$division = false;
	} else {
	$division = true;
	}
	if ($division == true) {//-
	if (($number / $quantity) == 53.0000) {//Aqu? le digo que cuando sea 53.0000 que lea el otro valor value_kit
	$rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value_kit'];
	} else {
	$rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value'];
	 }
	} else {
	if ($number == 53.0000) {//Aqu? le digo que cuando sea 53.0000 que lea el otro valor value_kit
	$rate = (tep_not_null($currency_value)) ? $currency_value : $this->currencies[$currency_type]['value_kit'];

	} else {
	$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) {//-
 if ($calculate_currency_value == true) {//-/
	if ($quantity == 0) {
	$division = false;
	} else {
	$division = true;
	}
  if ($division == true) {//
  if (($number / $quantity) == 53.0000) {
  return $this->currencies[$code]['value_kit'];
 } else {
  return $this->currencies[$code]['value'];
  }
/**/ } else {//
  if ($number == 53.0000) {
  return $this->currencies[$code]['value_kit'];
 } else {
  return $this->currencies[$code]['value'];
   }
  	  }//
 }//-/
}//-

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

//$account_query = tep_db_query("select products_id from" . TABLE_PRODUCTS . "");
//$sql_data_array['products_id'] = $products_id;
function display_price($products_price, $products_tax, $quantity = 1) {
  /*$price = $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
  if ($products_id == 102) {
  $products_price = "1.308,00";
  return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
  } else {*/
  return $this->format(tep_add_tax($products_price, $products_tax) * $quantity);
  //}
}
 }

 

How you can see, the change was with an a simple if and else... :P

 

I will thank any help...

thanks..

 

bye..

saludos! :-"

Link to comment
Share on other sites

I have already done something(on currencies.php), but the problem is when the subtotal cames in.... :P

 

How you can see, the change was with an a simple if and else... :P

 

I will thank any help...

thanks..

 

bye..

saludos! :-"

Not really, you changed the database table also and did a lot of hard coding. Nothing wrong with that, you have to maintain it :-"

 

bye ;)

Link to comment
Share on other sites

thanks... :)

the problem now, is when i buy more than 1 product with the different currencies.

For exemple, i buy 2 products, that of course it is the same product ;)

The price and the quantity become the double now...., so now doesn't work all the code i made...

Adding these on the code doesn't work ether... :(

if ($quantity == 0) {
	$division = false;
	} else {
	$division = true;
	}
  if ($division == true) {
  if (($number / $quantity) == 53.0000) {
  return $this->currencies[$code]['value_kit'];
 } else {
  return $this->currencies[$code]['value'];
  }
 } else {
  if ($number == 53.0000) {
  return $this->currencies[$code]['value_kit'];
 } else {
  return $this->currencies[$code]['value'];
   }
  	  }

 

What i'm doing wrong?? :'(

 

thanks..

bye.

Saludos! :-"

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...