Skip to main content

Set New Indian Rupee Currency Symbol in Opencart

In 2010 Indian Govt. has launched it's new currency symbol .
To use this new symbol in your website you can use &#8377; in your HTML, or if you are using font-awesome library then use <i class="fa fa-inr"></i>

In Opencart you can set currency symbol in localisation setting. If you have tried to copy new rupee symbol from somewhere and paste in Opencart setting. This will not work in some browsers because its not in UTF-8 format.
So to use it change the currency.php file in opencart-root/system/library/cart/currency.php (in case of opencart v2.3.x)



public function format($number, $currency, $value = '', $format = true) {
  $symbol_left = $this->currencies[$currency]['symbol_left'];
  $symbol_right = $this->currencies[$currency]['symbol_right'];
  $decimal_place = $this->currencies[$currency]['decimal_place'];

  if (!$value) {
   $value = $this->currencies[$currency]['value'];
  }

  $amount = $value ? (float)$number * $value : (float)$number;
  
  $amount = round($amount, (int)$decimal_place);
  
  if (!$format) {
   return $amount;
  }

  $string = '';

  // if ($symbol_left) {
  //  $string .= $symbol_left;
  // }
  if (($symbol_left) && ($format)) {
            if($currency=='INR')
             $string .='<i class="fa fa-inr"></i>';
            else
             $string .= $symbol_left;
        }

  $string .= number_format($amount, (int)$decimal_place, $this->language->get('decimal_point'), $this->language->get('thousand_point'));

  if ($symbol_right) {
   $string .= $symbol_right;
  }

  return $string;
 }

Comments

  1. will it work for Version 3.0.3.3 ?

    ReplyDelete
  2. Great services at reliable forex rates, fast processing, and excellent support. Perfect for students, travelers, and remittances. Highly recommend their user-friendly platform and offers!
    travel money exchange near me in Delhi
    currency exchange near Connaught Place Delhi
    best forex services in Noida and Gurgaon
    best forex exchange rates in Delhi

    ReplyDelete

Post a Comment

Popular posts from this blog

Main menu dropdown parent item clickable in Drupal 8 using Bootstrap 4

 Edit menu--main.html.twig template file {# /**  * @file  * Bootstrap Barrio's override to display a menu.  *  * Available variables:  * - menu_name: The machine name of the menu.  * - items: A nested list of menu items. Each menu item contains:  *   - attributes: HTML attributes for the menu item.  *   - below: The menu item child items.  *   - title: The menu link title.  *   - url: The menu link url, instance of \Drupal\Core\Url  *   - localized_options: Menu link localized options.  *   - is_expanded: TRUE if the link has visible children within the current  *     menu tree.  *   - is_collapsed: TRUE if the link has children within the current menu tree  *     that are not currently visible.  *   - in_active_trail: TRUE if the link is in the active trail.  */ #} {% import _self as menus...

Add JS to the bottom of the page in Drupal 7

How to add JS at bottom of a particular page in Drupal 7 Step 1: Get the page id. In case of front page "is_front"  Step 2: In template.php file of your theme add the below code : function illume_preprocess_page(&$variables) { if ($variables['is_front']) { drupal_add_js(path_to_theme().'/js/util.js', array('type' => 'file', 'scope' => 'footer')); drupal_add_js(path_to_theme().'/js/main.js', array('type' => 'file', 'scope' => 'footer')); drupal_add_js(path_to_theme().'/js/slideimage.js', array('type' => 'file', 'scope' => 'footer')); $variables['bottom_scripts'] = drupal_get_js(); } } This way you can add JS file using drupal_add_js() and define scope as footer. Step 3: Now you can use bottom_script variable to the page tpl file where you want to add JS print $bottom_scripts;

Use Case Diagram for Online Book Store