• Resolved s

    (@sdnazdi)


    Hi,

    Thanks for your nice CPT plugin.

    Your currency sign list is limited (only 34).

    Please complete your currency field->options->sign with more currencies in the world with their alphabet. You may check WooCommerce->Settings->General for instance.

    If it will not be soon, how I can add a currency sign to my need?

    • This topic was modified 11 months, 3 weeks ago by s.
    • This topic was modified 11 months, 3 weeks ago by s.
    • This topic was modified 11 months, 3 weeks ago by s.
    • This topic was modified 11 months, 3 weeks ago by s.
Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Paul Clark

    (@pdclark)

    The Pods currency sign list is filterable, therefore unlimited.

    Please add any currency you desire with the pods_form_ui_field_currency_currencies filter.

    You may check pods/classes/fields/currencies.php for instance.

    The filter mentioned and linked above will add any currency with any symbol and name. The filter in the same file, pods_form_ui_field_number_currency_default will also set a default.

    Here is an example of the use of these filters:

    <?php
    
    /**
     * Add currencies to the Pods currency field.
     * 
     * @see https://github.com/pods-framework/pods/blob/639cfa9255bd9d110c99ccfa4712eac327e2dfd2/classes/fields/currency.php#L568-L583C16
     */
    add_filter(
    	'pods_form_ui_field_currency_currencies',
    	function( $currencies ) {
    
    		/**
    		 * Iranian Rial.
    		 * 
    		 * @see https://en.wikipedia.org/wiki/Iranian_rial
    		 */
    		$currencies['irr'] = array(
    			'label'  => '???? ?????',
    			'name'   => 'Iranian Rial',
    			'sign'   => '?',
    			'entity' => '?',
    		);
    
    		/**
    		 * Monero.
    		 * 
    		 * @see https://en.wikipedia.org/wiki/Monero
    		 */
    		$currencies['xmr'] = array(
    			'label'  => 'Monero (XMR)',
    			'name'   => 'Monero',
    			'sign'   => 'XMR',
    			'entity' => 'XMR;',
    		);
    
    		return $currencies;
    	}
    );
    
    /**
     * Set default currency for Pods currency field.
     * 
     * @see https://github.com/pods-framework/pods/blob/639cfa9255bd9d110c99ccfa4712eac327e2dfd2/classes/fields/currency.php#L77
     */
    add_filter(
    	'pods_form_ui_field_number_currency_default',
    	function( $currency_code ) {
    		return 'irr';
    	}
    );

    The above code will add ? and XMR as currencies, with ? as the default.

    Various other attributes of the currency definition can also be filtered; try searching apply_filters( within the linked file.

    While it may seem to make sense to add all currently known international fiat currencies, of which there are around 180, there are also at least 22,932 cryptocurrencies in circulation, and as money is an imaginary social construct, there is really nothing keeping individuals from doing commerce in seashells, bananas, avocados, or futures contracts or digital coins representing these real things, or anything else.

    But I digress. The main idea is that money is a made-up concept, and the above filters will allow you to redefine that concept within the Pods currency field in any way you wish.

    Thread Starter s

    (@sdnazdi)

    Thanks @pdclark, it solved my question.

    Plugin Support Paul Clark

    (@pdclark)

    Oh good glad that helped.
    There was a typo for the XMR entity, it would not have a semicolon, as it is just the letters XMR, not an HTML entity.
    But sounds like it got you in the right direction.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Suggestion:Complete Currency list’ is closed to new replies.