Adding New Currency

Posted in: Developer Documentation

WPAdverts has a predefined list of currencies but you can easily add your own currency via Adverts API, please see the code below it will add Botswana Pula to currencies list, but you can easily customize the code to add different currency just change lines 17 to 19.

 

<?php
// The code below you can paste in your theme functions.php or create
// new plugin and paste the code there.
add_filter("adverts_currency_list", "add_adverts_currency");
/**
 * Add new currency to the list
 * 
 * @var $list Array list of currencies
 * @return Array updated list of currencies
 */ 
function add_adverts_currency($list) {
    
    $list[] = array(
        "code"=>"BWP", // ISO 4217 currency code, see http://en.wikipedia.org/wiki/ISO_4217
        "sign"=>"Pula", // currency prefix or postfix
        "label"=>"Botswana pula" // currency long name
    );
    
    return $list;
}