vkd1980 0 Posted June 14, 2012 (edited) Dear All, I am developing an online book shop. In their book store, Books imported from Other Countries and priced in other currencies.At the time of selling they are calculating the Price in Local currency by prevailing Exchange Rate. How can I implement the same in OSC ? . I have successfully done it in Ms Access. But I didn't know how to do it in OSC Logic I intended to use is in Products Table I Inserted one field Currency ID. In OSC I need In Admin side Selection of currency while updating Products In Front End what ever the currency Updated in Products Table ,I need to Show the Price in Default Currency, by taking the exchange rate updated in currecny table of respective Currency. for Example If £10 is Currency updated in Products Table In front End it should show as Rs 850/-( 10*85(Current Exchange Rate) if Rs 10 is Currency updated in Products Table In front End it should show as Rs10/-( 10*1(No Exchange Rate as default currency) if $10 Currency updated in Products Table In front End it should show as Rs550/-( 10*55(Current Exchange Rate) Please help me Edited June 14, 2012 by vkd1980 Share this post Link to post Share on other sites
vkd1980 0 Posted June 15, 2012 44 views No repliesssss Share this post Link to post Share on other sites
vkd1980 0 Posted June 15, 2012 Burt, Thank you for your reply, If we work on local currency manually while updating the Benefit of Exchange rate fluctuation will not get. In India there is a system for fixing the Exchange Rate of imported Books and periodicals. It done by goods office Committee and it will change only once in a month. but the store I am developing have more than 1000 Products of Imported Books. Its not an easy task to Update price of these products every month manually. that's why I looked the possibilities of Automating . I think that I need to Modify this "$currencies->display_price" function Please advice Share this post Link to post Share on other sites
vkd1980 0 Posted June 18, 2012 Dear all, I have changed the Currency class for the achieving Above, works fine, But I would Like to get an opinion from Experienced professionals about the code Change, and will it affect any other classes/Functions Please post your suggestions <?php /* $Id$ osCommerce, Open Source E-Commerce Solutions http://www.oscommerce.com Copyright (c) 2008 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']); } } // class methods function format($products_cur_id, $number, $calculate_currency_value = true, $currency_type = '', $currency_value = '') { global $currency; $curr_query = tep_db_query("select * from ".TABLE_CURRENCIES." where currencies_id='".(int)$products_cur_id."'"); $curr = tep_db_fetch_array($curr_query); if (empty($currency_type)) $currency_type = $currency; if ($calculate_currency_value == true) { $rate = (tep_not_null($currency_value)) ? $currency_value :$curr['value']; //$this->currencies[$currency_type]['value']; $format_string = $this->currencies[$currency_type]['symbol_left'] . number_format(tep_round($number * $rate, $curr['decimal_places']), $curr['decimal_places'], $curr['decimal_point'], $curr['thousands_point']) .$this->currencies[$currency_type]['symbol_right']; } else { $format_string = $curr['symbol_left'] . number_format(tep_round($number, $curr['decimal_places']), $curr['decimal_places'], $curr['decimal_point'], $curr['thousands_point']) . $this->currencies['symbol_right']; } // BOF: Store Mode if ((STORE_MODE == 'Maintenance') && (PRICES_OFF == 'true')) { $format_string = ''; } // EOF: Store Mode return $format_string; } function calculate_price($products_price, $products_tax, $quantity = 1) { global $currency; return tep_round(tep_add_tax($products_price, $products_tax), $this->currencies[$currency]['decimal_places']) * $quantity; } 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_cur_id, $products_price, $products_tax, $quantity = 1) { return $this->format($products_cur_id, $this->calculate_price($products_price, $products_tax, $quantity)); } } ?> Share this post Link to post Share on other sites