This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

reynierpm
reynierpm

As title said I'm access settings from component using Settings model in my plugin but got blank result instead the current stored at DB. This is what I'm doing. First this is my fields.yaml file definition:

fields:

sandbox_enabled:
  label: Activar modo Sandbox?
  type: checkbox
  default: false
ppal_fee:
  label: Cargo de PayPal
  type: text
ppal_discount:
  label: Descuento por transferencias
  type: text
ppal_app_id_sandbox:
  label: PayPal Sandbox App ID (*)
  type: text
ppal_developer_account:
  label: PayPal Developer Account Email Address (*)
  type: text
ppal_api_username_sandbox:
  label: PayPal Username API Credentials (Sandbox) (*)
  type: text
ppal_api_password_sandbox:
  label: PayPal Password API Credentials (Sandbox) (*)
  type: text
ppal_api_signature_sandbox:
  label: PayPal Signature API Credentials (Sandbox) (*)
  type: text
ppal_rest_client_id_sandbox:
  label: PayPal REST API Username Credentials (Sandbox) (*)
  type: text
ppal_rest_client_secret_sandbox:
  label: PayPal REST API Secret Credentials (Sandbox) (*)
  type: text

Second, alomicuba.recharge.settings record values at DB:

{

 "sandbox_enabled":"1",
 "ppal_fee":"0.029",
 "ppal_discount":"0.30",
 "ppal_app_id_sandbox":"",
 "ppal_developer_account":"",
 "ppal_api_username_sandbox":"",
 "ppal_api_password_sandbox":"",
 "ppal_api_signature_sandbox":"",
 "ppal_rest_client_id_sandbox":"",
 "ppal_rest_client_secret_sandbox":""

}

And finally how I'm getting the values for settings in my component:

public function onAmountChange()
{
    // The user amount
    $amount = post('amount');

    if (empty($amount))
    {
        throw new \Exception(sprintf('Por favor introduzca un valor.'));
    }

    $toReload = $amount - ($amount * Settings::get('ppal_fee') - Settings::get('ppal_discount'));
    $this->page["confirmation_text"] = $toReload;
}

But it's not working since this two values Settings::get('ppal_fee'), Settings::get('ppal_discount') comes empty, why? What I did wrong?

daftspunky
daftspunky

Try this

$toReload = $amount - ($amount * (float) Settings::get('ppal_fee') - (float) Settings::get('ppal_discount'));
reynierpm
reynierpm

Hi @daftpunks this is not the problem, the problem is that Settings::get('ppal_fee') and Settings::get('ppal_discount') gets NULL or no value and for that reason the calculation is failing

1-3 of 3

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.