Instantly share code, notes, and snippets.

Embed
What would you like to do?
Get Gravity Forms to select a better landing page with PayPal Standard, and make your credit card customers happier. https://snippets.webaware.com.au/snippets/select-paypal-landing-page-for-easy-digital-downloads/
<?php
/*
Plugin Name: GF PayPal Standard billing Page
Plugin URI: https://gist.github.com/webaware/a3172f7f81ff56cd844d7adca92726a6
Description: Get Gravity Forms to select a better landing page with PayPal Standard, and make your credit card customers happier.
Version: 1
Author: WebAware
Author URI: https://shop.webaware.com.au/
*/
/*
copyright (c) 2018 WebAware Pty Ltd (email : support@webaware.com.au)
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
if (!defined('ABSPATH')) {
exit;
}
add_filter('gform_paypal_query', function($query_string, $form, $entry, $feed) {
// select the Billing landing page, which makes the Credit Card fields more obvious
$query_string .= '&landing_page=Billing';
// attempt to set the country code, for a better customer experience
if (!empty($feed['meta']['billingInformation_country'])) {
$country = rgar($entry, $feed['meta']['billingInformation_country']);
if ($country) {
$country_code = GF_Fields::get_instance('address')->get_country_code($country);
if ($country_code) {
$query_string .= '&lc=' . $country_code;
}
}
}
return $query_string;
}, 10, 4);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment