Created
February 27, 2018 15:44
-
-
Save New0/bce0e937147ccb5f054ab42ecdb27286 to your computer and use it in GitHub Desktop.
Set Caldera Forms Paypal express currency conditionally with a dropdown select field.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?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