WooCommerce PayPal Express Checkout Payment Gateway - Version 1.6.12

Version Description

  • 2019-05-08 =
  • Fix - Better handling of virtual subscriptions when billing address is not required
  • Fix - Prevent errors showing when purchasing a virtual product with WP_DEBUG enabled
Download this release

Release Info

Developer woothemes
Plugin Icon 128x128 WooCommerce PayPal Express Checkout Payment Gateway
Version 1.6.12
Comparing to
See all releases

Code changes from version 1.6.11 to 1.6.12

changelog.txt CHANGED
@@ -1,5 +1,9 @@
1
  *** Changelog ***
2
 
 
 
 
 
3
  = 1.6.11 - 2019-04-17 =
4
  * Fix/Performance - Prevent db option updates during bootstrap on each page load
5
  * Tweak = WC 3.6 compatibiliy.
1
  *** Changelog ***
2
 
3
+ = 1.6.12 - 2019-05-08 =
4
+ * Fix - Better handling of virtual subscriptions when billing address is not required
5
+ * Fix - Prevent errors showing when purchasing a virtual product with WP_DEBUG enabled
6
+
7
  = 1.6.11 - 2019-04-17 =
8
  * Fix/Performance - Prevent db option updates during bootstrap on each page load
9
  * Tweak = WC 3.6 compatibiliy.
includes/class-wc-gateway-ppec-checkout-handler.php CHANGED
@@ -513,12 +513,14 @@ class WC_Gateway_PPEC_Checkout_Handler {
513
  $customer->set_billing_state( $billing_details['state'] );
514
  $customer->set_billing_country( $billing_details['country'] );
515
 
516
- $customer->set_shipping_address( $shipping_details['address_1'] );
517
- $customer->set_shipping_address_2( $shipping_details['address_2'] );
518
- $customer->set_shipping_city( $shipping_details['city'] );
519
- $customer->set_shipping_postcode( $shipping_details['postcode'] );
520
- $customer->set_shipping_state( $shipping_details['state'] );
521
- $customer->set_shipping_country( $shipping_details['country'] );
 
 
522
  }
523
 
524
  /**
@@ -981,12 +983,14 @@ class WC_Gateway_PPEC_Checkout_Handler {
981
 
982
  $destination = $this->get_mapped_shipping_address( $checkout_details );
983
 
984
- $packages[0]['destination']['country'] = $destination['country'];
985
- $packages[0]['destination']['state'] = $destination['state'];
986
- $packages[0]['destination']['postcode'] = $destination['postcode'];
987
- $packages[0]['destination']['city'] = $destination['city'];
988
- $packages[0]['destination']['address'] = $destination['address_1'];
989
- $packages[0]['destination']['address_2'] = $destination['address_2'];
 
 
990
 
991
  return $packages;
992
  }
513
  $customer->set_billing_state( $billing_details['state'] );
514
  $customer->set_billing_country( $billing_details['country'] );
515
 
516
+ if ( ! empty( $shipping_details ) ) {
517
+ $customer->set_shipping_address( $shipping_details['address_1'] );
518
+ $customer->set_shipping_address_2( $shipping_details['address_2'] );
519
+ $customer->set_shipping_city( $shipping_details['city'] );
520
+ $customer->set_shipping_postcode( $shipping_details['postcode'] );
521
+ $customer->set_shipping_state( $shipping_details['state'] );
522
+ $customer->set_shipping_country( $shipping_details['country'] );
523
+ }
524
  }
525
 
526
  /**
983
 
984
  $destination = $this->get_mapped_shipping_address( $checkout_details );
985
 
986
+ if ( ! empty( $destination ) ) {
987
+ $packages[0]['destination']['country'] = $destination['country'];
988
+ $packages[0]['destination']['state'] = $destination['state'];
989
+ $packages[0]['destination']['postcode'] = $destination['postcode'];
990
+ $packages[0]['destination']['city'] = $destination['city'];
991
+ $packages[0]['destination']['address'] = $destination['address_1'];
992
+ $packages[0]['destination']['address_2'] = $destination['address_2'];
993
+ }
994
 
995
  return $packages;
996
  }
includes/class-wc-gateway-ppec-with-paypal-addons.php CHANGED
@@ -39,6 +39,73 @@ class WC_Gateway_PPEC_With_PayPal_Addons extends WC_Gateway_PPEC_With_PayPal {
39
 
40
  add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
41
  add_action( 'woocommerce_subscription_failing_payment_method_' . $this->id, array( $this, 'update_failing_payment_method' ) );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
42
  }
43
 
44
  /**
39
 
40
  add_action( 'woocommerce_scheduled_subscription_payment_' . $this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 );
41
  add_action( 'woocommerce_subscription_failing_payment_method_' . $this->id, array( $this, 'update_failing_payment_method' ) );
42
+ add_filter( 'woocommerce_payment_gateways_renewal_support_status_html', array( $this, 'subscription_tooltip' ), 10, 2 );
43
+ add_filter( 'woocommerce_available_payment_gateways', array( $this, 'get_available_gataways_for_subscriptions' ), 20 );
44
+ }
45
+
46
+ /**
47
+ * Filter for Subscriptions info tooltip html for this gateway
48
+ *
49
+ * @since 1.6.12
50
+ *
51
+ * @param string $html HTML of the tooltip
52
+ * @param WC_Payment_Gateway $gateway Payment gateway to filter for
53
+ *
54
+ * @return string Filtered HTML
55
+ */
56
+ public function subscription_tooltip( $html, $gateway ) {
57
+ if ( $gateway->id !== $this->id ) {
58
+ return $html;
59
+ }
60
+ if ( 'no' === $gateway->get_option( 'require_billing', 'no' ) ) {
61
+ $tool_tip = esc_attr__( 'You must enable the "Require billing address" option to support this gateway\'s features for virtual subscriptions.', 'woocommerce-gateway-paypal-express-checkout' );
62
+ $status = esc_html__( 'Maybe', 'woocommerce-gateway-paypal-express-checkout' );
63
+ $html = sprintf( '<span class="payment-method-features-info tips" data-tip="%1$s">%2$s</span>',
64
+ $tool_tip,
65
+ $status );
66
+ }
67
+ return $html;
68
+ }
69
+
70
+ /**
71
+ * Filter determining whether to show this gateway during checkout
72
+ *
73
+ * @since 1.6.12
74
+ *
75
+ * @param array $gateways Array of payment gateways
76
+ *
77
+ * @return array Filtered array of payment gateways
78
+ */
79
+ public function get_available_gataways_for_subscriptions( $gateways ) {
80
+ if ( ! $this->should_display_buttons_at_checkout() ) {
81
+ unset( $gateways['ppec_paypal'] );
82
+ }
83
+ return $gateways;
84
+ }
85
+
86
+ /**
87
+ * Checks if smart payment buttons can be displayed during the checkout
88
+ *
89
+ * @since 1.6.12
90
+ *
91
+ * @return bool True if buttons can be displayed
92
+ */
93
+ public function should_display_buttons_at_checkout() {
94
+ if ( ! class_exists( 'WC_Subscriptions_Product' )
95
+ || ! WC()->cart
96
+ || 'yes' === $this->get_option( 'require_billing', 'no' ) ) {
97
+ return true;
98
+ }
99
+ $cart_contents = WC()->cart->cart_contents;
100
+ if ( empty( $cart_contents ) ) {
101
+ return true;
102
+ }
103
+ foreach ( WC()->cart->cart_contents as $cart_item ) {
104
+ if ( WC_Subscriptions_Product::is_subscription( $cart_item['data'] ) && ! $cart_item['data']->needs_shipping() ) {
105
+ return false;
106
+ }
107
+ }
108
+ return true;
109
  }
110
 
111
  /**
includes/class-wc-gateway-ppec-with-spb-addons.php CHANGED
@@ -19,6 +19,9 @@ class WC_Gateway_PPEC_With_SPB_Addons extends WC_Gateway_PPEC_With_PayPal_Addons
19
  * Display PayPal button on the checkout page order review.
20
  */
21
  public function display_paypal_button() {
 
 
 
22
  wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' );
23
  ?>
24
  <div id="woo_pp_ec_button_checkout"></div>
@@ -51,7 +54,7 @@ class WC_Gateway_PPEC_With_SPB_Addons extends WC_Gateway_PPEC_With_PayPal_Addons
51
  $session->checkout_completed = true;
52
  $session->payer_id = $_POST['payerID'];
53
  $session->token = $_POST['paymentToken'];
54
-
55
  WC()->session->set( 'paypal', $session );
56
  }
57
 
19
  * Display PayPal button on the checkout page order review.
20
  */
21
  public function display_paypal_button() {
22
+ if ( ! $this->should_display_buttons_at_checkout() ) {
23
+ return;
24
+ }
25
  wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' );
26
  ?>
27
  <div id="woo_pp_ec_button_checkout"></div>
54
  $session->checkout_completed = true;
55
  $session->payer_id = $_POST['payerID'];
56
  $session->token = $_POST['paymentToken'];
57
+
58
  WC()->session->set( 'paypal', $session );
59
  }
60
 
includes/class-wc-gateway-ppec-with-spb.php CHANGED
@@ -19,6 +19,9 @@ class WC_Gateway_PPEC_With_SPB extends WC_Gateway_PPEC_With_PayPal {
19
  * Display PayPal button on the checkout page order review.
20
  */
21
  public function display_paypal_button() {
 
 
 
22
  wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' );
23
  ?>
24
  <div id="woo_pp_ec_button_checkout"></div>
@@ -51,7 +54,7 @@ class WC_Gateway_PPEC_With_SPB extends WC_Gateway_PPEC_With_PayPal {
51
  $session->checkout_completed = true;
52
  $session->payer_id = $_POST['payerID'];
53
  $session->token = $_POST['paymentToken'];
54
-
55
  WC()->session->set( 'paypal', $session );
56
  }
57
 
19
  * Display PayPal button on the checkout page order review.
20
  */
21
  public function display_paypal_button() {
22
+ if ( ! $this->should_display_buttons_at_checkout() ) {
23
+ return;
24
+ }
25
  wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' );
26
  ?>
27
  <div id="woo_pp_ec_button_checkout"></div>
54
  $session->checkout_completed = true;
55
  $session->payer_id = $_POST['payerID'];
56
  $session->token = $_POST['paymentToken'];
57
+
58
  WC()->session->set( 'paypal', $session );
59
  }
60
 
readme.txt CHANGED
@@ -2,8 +2,8 @@
2
  Contributors: automattic, woothemes, akeda, dwainm, royho, allendav, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, mikaey, fullysupportedphil, dsmithweb, corsonr, bor0, zandyring, pauldechov, robobot3000
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal
4
  Requires at least: 4.4
5
- Tested up to: 5.0.3
6
- Stable tag: 1.6.11
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -101,6 +101,10 @@ Please use this to inform us about bugs, or make contributions via PRs.
101
 
102
  == Changelog ==
103
 
 
 
 
 
104
  = 1.6.11 - 2019-04-17 =
105
  * Fix/Performance - Prevent db option updates during bootstrap on each page load
106
  * Tweak = WC 3.6 compatibiliy.
2
  Contributors: automattic, woothemes, akeda, dwainm, royho, allendav, slash1andy, woosteve, spraveenitpro, mikedmoore, fernashes, shellbeezy, danieldudzic, mikaey, fullysupportedphil, dsmithweb, corsonr, bor0, zandyring, pauldechov, robobot3000
3
  Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal
4
  Requires at least: 4.4
5
+ Tested up to: 5.2.0
6
+ Stable tag: 1.6.12
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
101
 
102
  == Changelog ==
103
 
104
+ = 1.6.12 - 2019-05-08 =
105
+ * Fix - Better handling of virtual subscriptions when billing address is not required
106
+ * Fix - Prevent errors showing when purchasing a virtual product with WP_DEBUG enabled
107
+
108
  = 1.6.11 - 2019-04-17 =
109
  * Fix/Performance - Prevent db option updates during bootstrap on each page load
110
  * Tweak = WC 3.6 compatibiliy.
woocommerce-gateway-paypal-express-checkout.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce PayPal Checkout Gateway
4
  * Plugin URI: https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/
5
  * Description: A payment gateway for PayPal Checkout (https://www.paypal.com/us/webapps/mpp/paypal-checkout).
6
- * Version: 1.6.11
7
  * Author: WooCommerce
8
  * Author URI: https://woocommerce.com
9
  * Copyright: © 2018 WooCommerce / PayPal.
@@ -27,7 +27,7 @@ if ( ! defined( 'ABSPATH' ) ) {
27
  exit; // Exit if accessed directly
28
  }
29
 
30
- define( 'WC_GATEWAY_PPEC_VERSION', '1.6.11' );
31
 
32
  /**
33
  * Return instance of WC_Gateway_PPEC_Plugin.
3
  * Plugin Name: WooCommerce PayPal Checkout Gateway
4
  * Plugin URI: https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/
5
  * Description: A payment gateway for PayPal Checkout (https://www.paypal.com/us/webapps/mpp/paypal-checkout).
6
+ * Version: 1.6.12
7
  * Author: WooCommerce
8
  * Author URI: https://woocommerce.com
9
  * Copyright: © 2018 WooCommerce / PayPal.
27
  exit; // Exit if accessed directly
28
  }
29
 
30
+ define( 'WC_GATEWAY_PPEC_VERSION', '1.6.12' );
31
 
32
  /**
33
  * Return instance of WC_Gateway_PPEC_Plugin.