gform_ppcp_object

Description

The gform_ppcp_object filter can be used to customize the GFPPCP object that is included in the form initialization scripts for the PayPal Field which is available with the PayPal Checkout Add-On.

Usage

The following would apply to all forms:

add_filter( 'gform_ppcp_object', 'your_function_name', 10, 2 );

Parameters

  • $args array

    An array of arguments which control the appearance and behaviour of the PayPal Checkout and Credit Card field. Example:

    array(
    	'formId'              => 1,
    	'isAjax'              => false,
    	'currency'            => 'USD',
    	'feeds'               => array(),
    	'smartPaymentButtons' => array(
    		'buttonsLayout' => 'vertical',
    		'buttonsSize'   => 'responsive',
    		'buttonsShape'  => 'rect',
    		'buttonsColor'  => 'gold',
    	),
    	'ccFieldID'           => 4,
    	'ccPage'              => 1,
    	'paymentMethods'      => array(
    		array( 'text' => 'PayPal Checkout', 'value' => 'PayPal Checkout' ),
    		array( 'text' => 'Credit Card', 'value' => 'Credit Card' )
    	),
    	'cardStyle'           => array(),
    );
        

  • $form_id int

    The ID of the form containing the PayPal Field being prepared for display.

Example

This example shows how you can change the PayPal Smart Payment Buttons shape.

add_filter( 'gform_ppcp_object', 'ppcp_object_buttons_shape', 10, 2 );
function ppcp_object_buttons_shape( $args, $form_id ) {
	$args['smartPaymentButtons']['buttonsShape'] = 'pill';
	return $args;
}

Placement

This code should be placed in the functions.php file of your active theme.

Source Code

$args = apply_filters( 'gform_ppcp_object', $args, $form['id'] );

This filter is located in GF_PPCP::register_init_scripts() in class-gf-ppcp.php.