Convert Price into Reward points

To show price as points , You can implement following logic

  • create a custom currency "Reward Points"

  • Allow "Reward Points" custom currency from admin panel currency
    settings

  • Set currency set for "Reward Points" 10 = 1 USD

  • set Default Display Currency to "Reward Points"

We accused Custom Currency code for Reward Points is "PTS" (as "INR" for Indian Rupee)

You can follow below steps to implement above logic.

step 1) open YOUR-MAGENTO-ROOT-DIRECTORY/vendor/magento/zendframework1/library/Zend/Locale/Data/en.xml

Under currencies xml entity , enter your custom currency entiry (i.e "Reward Points") as follows and save the xml file.

<currencies>
----------------
<currency type="PTS">
   <displayName>Reward Points</displayName>
   <displayName count="one">Reward Points</displayName>
   <displayName count="other">Reward Points</displayName>
   <symbol>points</symbol> 
</currency>
----------------
</currencies>

step 2: open YOUR-MAGENTO-ROOT-DIRECTORY/vendor/magento/zendframework1/library/Zend/Locale/Data/en.xml

under installed XML entity enter your custom currency code as below

<system>
<currency>
<installed>PTS,AZN,AZM,AFN,ALL,DZD,AOA,ARS,AMD,AWG,AUD,BSD,BHD,BDT,BBD,BYR,BZD,BMD,BTN,BOB,BAM,BWP,BRL,GBP,BND,BGN,BUK,BIF,KHR,CAD,CVE,CZK,KYD,CLP,CNY,COP,KMF,CDF,CRC,HRK,CUP,DKK,DJF,DOP,XCD,EGP,SVC,GQE,ERN,EEK,ETB,EUR,FKP,FJD,GMD,GEK,GEL,GHS,GIP,GTQ,GNF,GYD,HTG,HNL,HKD,HUF,ISK,INR,IDR,IRR,IQD,ILS,JMD,JPY,JOD,KZT,KES,KWD,KGS,LAK,LVL,LBP,LSL,LRD,LYD,LTL,MOP,MKD,MGA,MWK,MYR,MVR,LSM,MRO,MUR,MXN,MDL,MNT,MAD,MZN,MMK,NAD,NPR,ANG,TRL,TRY,NZD,NIC,NGN,KPW,NOK,OMR,PKR,PAB,PGK,PYG,PEN,PHP,PLN,QAR,RHD,RON,ROL,RUB,RWF,SHP,STD,SAR,RSD,SCR,SLL,SGD,SKK,SBD,SOS,ZAR,KRW,LKR,SDG,SRD,SZL,SEK,CHF,SYP,TWD,TJS,TZS,THB,TOP,TTD,TND,TMM,USD,UGX,UAH,AED,UYU,UZS,VUV,VEB,VEF,VND,CHE,CHW,XOF,XPF,WST,YER,ZMK,ZWD</installed>
</currency>
</system>

step 3: Create a custom extension or use any exiting custom extension

step 4: we assumed , we are using custom extension Company_MyModule

step 5: craete file AddCurrencies.php under app/code/Company/MyModule/Model/Config

File AddCurrencies.php

<?php
namespace Company\MyModule\Model\Config;

use Magento\Framework\Locale\Bundle\CurrencyBundle;

class AddCurrencies extends \Magento\Framework\Locale\TranslatedLists
{

    public function getNewCurrencies() 
    {
        /* 
           This is your function that returns an array with new
           currencies. For example: 
         */
        return [
            ['value' => 'PTS', 'label' => 'Reward Points'],            
        ];
    }

    public function getOptionAllCurrencies()
    {
        $currencyBundle = new \Magento\Framework\Locale\Bundle\CurrencyBundle();
        $locale = $this->localeResolver->getLocale();
        $currencies = $currencyBundle->get($locale)['Currencies'] ?: [];

        $options = [];
        foreach ($currencies as $code => $data) {
            $options[] = ['label' => $data[1], 'value' => $code];
        }
        $options = array_merge($options, $this->getNewCurrencies());

        return $this->_sortOptionArray($options);
    }

    public function getOptionCurrencies()
    {
        $currencies = (new CurrencyBundle())->get($this->localeResolver->getLocale())['Currencies'] ?: [];
        $options = [];
        $allowed = $this->_config->getAllowedCurrencies();
        foreach ($currencies as $code => $data) {
            if (!in_array($code, $allowed)) {
                continue;
            }
            $options[] = ['label' => $data[1], 'value' => $code];
        }
        $options = array_merge($options, $this->getNewCurrencies());

        return $this->_sortOptionArray($options);
    }


}

step 6: Run following CLI command from your Magento 2 root directory to clear static contend and generated files

sudo rm -rf var/view_preprocessed/*
sudo rm -rf var/pub/static/*
sudo rm -rf var/cache/*
sudo rm -rf var/generated

step 7: Again run following CLI command from your Magento 2 root directory

sudo php bin/magento setup:upgrade
sudo php bin/magento setup:di:compile
sudo chmod -Rv 777 pub var generated

step 8: Please go to admin panel and navigate Stores->Configuration-> Currency Setup (under general tab) Select "Reward Points" and "US Dollar" as Allowed Currencies. now click "Save Config" button.

Step 9: Please go to Admin panel Stores-> Currency Rates Now enter Currency rate for "PTS" (i.e Reward Points) as 10.00 = 1 USD click "Save Currency Rates"

Step 10: Refresh Cache from System-> Cache Management

step 11: To display Price in Points, Please go to admin panel and navigate Stores->Configuration-> Currency Setup (under general tab) set Default Display Currency = Reward Points click "Save Config"

step 12: Please refresh cache again to show price in Points

Allowed Currency setting

Price With USD

enter image description here