Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Warning: explode() [function.explode]: Empty delimiter


JSR

Recommended Posts

Hi guys,

 

So I'm getting this error:

Warning: explode() [function.explode]: Empty delimiter in .../includes/classes/currencies.php on line 55

 

And I just don't understand where it's coming from!

Line 55 says:

$format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);

 

And also if I use the currencies box to click on the default currency or switch to another currency, this error disappears.

My default currency is USD and I also have euro and gbp.

 

Does anybody know what could be the issue here?

Link to comment
Share on other sites

Hi multimixer,

 

Thanks for replying!

I do have a dot in admin where the decimal point must be inserted....

So that's not the problem..

Link to comment
Share on other sites

There is no function explode() in file classes/currencies.php by default

 

Can you say what version you are using, if you modified that file in any way and place the complete contents of classes/currencies to here?

 

Please use <> (code tags) for this, like this

This is in code tags

Link to comment
Share on other sites

Hi multimixer,

 

I just checked the vanilla osC classes/currencies.php and sure enough you're right!!

It seems I changed the format function. Mine looks like this now...

I don't remember doing that though.... I'm just going to revert back to the original function...

 

// 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'];
		  $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
		  $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . $format_string[1];
	    } 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'];
		  $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
		  $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . $format_string[1];

	    }								 

  return $format_string;
   }

Link to comment
Share on other sites

Hi multimixer,

 

Thanks for replying!

I do have a dot in admin where the decimal point must be inserted....

So that's not the problem..

 

Check and be sure that's true for all the currencies.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Hi Germ,

 

I have 3 currencies installed (USD default) and all have a dot inserted as decimal point...

English is the only language and language currency is defined as USD.

I also have use default language of currency set to true in admin configuration...

Link to comment
Share on other sites

Ok, here goes...

<?php
/*
 $Id: currencies.php,v 1.16 2003/06/05 23:16:46 hpdl Exp $
 osCommerce, Open Source E-Commerce Solutions
 http://www.oscommerce.com
 Copyright (c) 2003 osCommerce
 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']);
  }
   }

   ///Begin of addition to currencies.php for deposit(deposit payments) mod
function price() {
    global $order;
    $number = $order->info['total'];
    $currency_value = $order->info['currency_value'];
    $rate = (tep_not_null($currency_value)) ? $currency_value :
$this->currencies[$currency_type]['value'];
    $price =  round (($rate * $number), 2)  ;
    return $price;
   }
//End of addition to currencies.php for deposit (deposit payments) mod
// 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'];
		  $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
		  $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . $format_string[1];
	    } 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'];
		  $format_string = explode($this->currencies[$currency_type]['decimal_point'], $format_string);
		  $format_string = $format_string[0] . $this->currencies[$currency_type]['decimal_point'] . $format_string[1];

	    }								 

  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

After this line of code:

 

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

 

ADD this code:

 

if ( $this->currencies[$currency_type]['decimal_point'] == '' ) {
  $this->currencies[$currency_type]['decimal_point'] = '.';
}

 

This fix is only a "band-aid". It just covers up a problem somewhere else. Where ? - I haven't a clue....

 

As long as all your currencies use a period for the 'decimal_point" it should work.

 

Cross your fingers another error doesn't pop up somewhere else.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

Hi germ,

 

Thanks for the band aid, but all prices turn up as "0." right now.

I'm completely lost :'(

All currencies have use a period forthe decimal point so I don't even know where to look anymore...

Link to comment
Share on other sites

I'm going to go out on a limb and guess the site's been around a while due to the fact it's ancient osC code and has some "non-standard" code applied (maybe an "addon" installed).

 

I'm also guessing it used to work fine, then something happened to cause the error you first posted about.

 

So maybe if you elaborate on how you've wound up where you are now we can backtrack and find the malfunction.

 

Without a little history I wouldn't know where to start looking either.

If I suggest you edit any file(s) make a backup first - I'm not perfect and neither are you.

 

"Given enough impetus a parallelogramatically shaped projectile can egress a circular orifice."

- Me -

 

"Headers already sent" - The definitive help

 

"Cannot redeclare ..." - How to find/fix it

 

SSL Implementation Help

 

Like this post? "Like" it again over there >

Link to comment
Share on other sites

You're absolutely right, germ!! Ok, so I finally figured it out... Please don't be mad at me guys.... >_<

I have an alteration in application_top that gets the customer country from the ip address and changes the currency accordingly.

But I also removed countries that I don't ship to.

So last year I moved to a country that isn't listed in admin.

That's why prices where showing up as 0 (even with the default code); my country ip could not be verified anymore... :blush:

I'm so very sorry about bothering you guys with this issue when it's something that you had no way of knowing in the 1st place...

Please accept my apologies :sweating:

Link to comment
Share on other sites

Yeah, definitely! Germ's post led me in the right direction, because I had totally forgotten about the addon.... :unsure:

It's a good thing though, cause now I know how the site looks for people in unlisted countries...

Thanks again guys! ^_^

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...