Skip to content

Instantly share code, notes, and snippets.

@New0
Created February 27, 2018 15:44
Show Gist options
  • Select an option

  • Save New0/bce0e937147ccb5f054ab42ecdb27286 to your computer and use it in GitHub Desktop.

Select an option

Save New0/bce0e937147ccb5f054ab42ecdb27286 to your computer and use it in GitHub Desktop.
Set Caldera Forms Paypal express currency conditionally with a dropdown select field.
<?php
add_filter( 'cf_paypal_request', function( $request, $process, $form ) {
//SET THE FORM ID AND THE FIELD ID ( DROPDOWN FIELD WITH CURRENCY OPTIONS )
$form_id = 'CF5a5e8452c6f82';
$field_id = 'fld_8085538';
if ( $form['ID'] === $form_id ) {
if ( $process['data'][$field_id] === 'USD' ) {
$request[ 'PAYMENTREQUEST_0_CURRENCYCODE' ] = 'USD';
} else if ( $process['data'][$field_id] === 'EUR' ) {
$request[ 'PAYMENTREQUEST_0_CURRENCYCODE' ] = 'EUR';
} else if ( $process['data'][$field_id] === 'CAD' ) {
$request[ 'PAYMENTREQUEST_0_CURRENCYCODE' ] = 'CAD';
}
}
return $request;
}, 10, 3);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment