1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How do I add PLN currency to user upgrade system?

Discussion in 'XenForo Questions and Support' started by jacko, Sep 26, 2011.

  1. jacko

    jacko Active Member

    Currently there is no PLN in the currency list.
     
  2. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    The allowed currencies are hard-coded. It is messy to make this change yourself. Ideally the devs should add more currencies.

    Try manually editing xf_user_upgrade.cost_currency in the database to change the currency for an existing upgrade. Use phpmyadmin or run a query like this:

    Code:
    UPDATE xf_user_upgrade
    SET cost_currency = 'pln';
    
    The new currency appears to work fine once you change it in the database. But you should do some test payments afterwards to be sure.

    Be aware that the currency type will reset when you edit the upgrade in the Admin CP because it hasn't been properly added to the software yet.
     
    jacko likes this.
  3. jacko

    jacko Active Member

    Perhaps there is a file that I could edit and add PLN there?
     
  4. Jake Bunce

    Jake Bunce XenForo Moderator Staff Member

    library/XenForo/DataWriter/UserUpgrade.php

    Code:
    	protected function _getFields()
    	{
    		return array(
    			'xf_user_upgrade' => array(
    				'user_upgrade_id'      => array('type' => self::TYPE_UINT,    'autoIncrement' => true),
    				'title'                => array('type' => self::TYPE_STRING,  'required' => true, 'maxLength' => 50,
    						'requiredError' => 'please_enter_valid_title'
    				),
    				'description'          => array('type' => self::TYPE_STRING,  'default' => ''),
    				'display_order'        => array('type' => self::TYPE_UINT,    'default' => 0),
    				'extra_group_ids'      => array('type' => self::TYPE_UNKNOWN, 'default' => '',
    						'verification' => array('$this', '_verifyExtraGroupIds')
    				),
    				'recurring'            => array('type' => self::TYPE_BOOLEAN, 'default' => 0),
    				'cost_amount'          => array('type' => self::TYPE_FLOAT,   'required' => true,
    						'verification' => array('$this', '_verifyCostAmount')
    				),
    				'cost_currency'        => array('type' => self::TYPE_STRING,  'required' => true,
    						'allowedValues' => array('usd', 'cad', 'aud', 'gbp', 'eur')
    				),
    				'length_amount'        => array('type' => self::TYPE_UINT,    'required' => true),
    				'length_unit'          => array('type' => self::TYPE_STRING,  'default' => '',
    						'allowedValues' => array('day', 'month', 'year', '')
    				),
    				'disabled_upgrade_ids' => array('type' => self::TYPE_UNKNOWN, 'default' => '',
    						'verification' => array('$this', '_verifyDisabledUpgradeIds')
    				),
    				'can_purchase'         => array('type' => self::TYPE_BOOLEAN, 'default' => 1),
    			)
    		);
    	}
    
    Admin CP -> Development -> Admin Templates -> user_upgrade_edit

    Code:
    	<xen:controlunit label="{xen:phrase cost}:">
    		<xen:textbox name="cost_amount" value="{$upgrade.cost_amount}" size="3" />
    		<xen:select name="cost_currency" value="{$upgrade.cost_currency}" inputclass="autoSize">
    			<xen:option value="usd">USD</xen:option>
    			<xen:option value="cad">CAD</xen:option>
    			<xen:option value="aud">AUD</xen:option>
    			<xen:option value="gbp">GBP</xen:option>
    			<xen:option value="eur">EUR</xen:option>
    		</xen:select>
    	</xen:controlunit>
    
    Changes to the admin templates and files will be overwritten during an upgrade.
     
    CNK and jacko like this.
  5. Dinh Thanh

    Dinh Thanh Well-Known Member

    Deriel, CNK and Jake Bunce like this.

Share This Page