WooCommerce PayPal Express Checkout Payment Gateway - Version 1.4.1

Version Description

  • Fix - Properly calculate whether Billing phone is required or not.
  • Fix - Set NOSHIPPING based on product shipping requiredness (e.g. virtual products do not need shipping, etc)
Download this release

Release Info

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

Code changes from version 1.4.0 to 1.4.1

includes/class-wc-gateway-ppec-cart-handler.php CHANGED
@@ -209,7 +209,7 @@ class WC_Gateway_PPEC_Cart_Handler {
209
  wp_enqueue_style( 'wc-gateway-ppec-frontend-cart', wc_gateway_ppec()->plugin_url . 'assets/css/wc-gateway-ppec-frontend-cart.css' );
210
 
211
  if ( is_cart() ) {
212
- wp_enqueue_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), '1.0', true );
213
  wp_enqueue_script( 'wc-gateway-ppec-frontend-in-context-checkout', wc_gateway_ppec()->plugin_url . 'assets/js/wc-gateway-ppec-frontend-in-context-checkout.js', array( 'jquery' ), wc_gateway_ppec()->version, true );
214
  wp_localize_script( 'wc-gateway-ppec-frontend-in-context-checkout', 'wc_ppec_context',
215
  array(
209
  wp_enqueue_style( 'wc-gateway-ppec-frontend-cart', wc_gateway_ppec()->plugin_url . 'assets/css/wc-gateway-ppec-frontend-cart.css' );
210
 
211
  if ( is_cart() ) {
212
+ wp_enqueue_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true );
213
  wp_enqueue_script( 'wc-gateway-ppec-frontend-in-context-checkout', wc_gateway_ppec()->plugin_url . 'assets/js/wc-gateway-ppec-frontend-in-context-checkout.js', array( 'jquery' ), wc_gateway_ppec()->version, true );
214
  wp_localize_script( 'wc-gateway-ppec-frontend-in-context-checkout', 'wc_ppec_context',
215
  array(
includes/class-wc-gateway-ppec-checkout-handler.php CHANGED
@@ -145,7 +145,7 @@ class WC_Gateway_PPEC_Checkout_Handler {
145
  $require_phone_number = wc_gateway_ppec()->settings->require_phone_number;
146
 
147
  if ( array_key_exists( 'billing_phone', $billing_fields ) ) {
148
- $billing_fields['billing_phone']['required'] = 'no' !== $require_phone_number;
149
  };
150
 
151
  return $billing_fields;
@@ -295,6 +295,10 @@ class WC_Gateway_PPEC_Checkout_Handler {
295
  return;
296
  }
297
 
 
 
 
 
298
  ?>
299
  <h3><?php _e( 'Shipping details', 'woocommerce-gateway-paypal-express-checkout' ); ?></h3>
300
  <?php
145
  $require_phone_number = wc_gateway_ppec()->settings->require_phone_number;
146
 
147
  if ( array_key_exists( 'billing_phone', $billing_fields ) ) {
148
+ $billing_fields['billing_phone']['required'] = 'yes' === $require_phone_number;
149
  };
150
 
151
  return $billing_fields;
295
  return;
296
  }
297
 
298
+ if ( ! WC_Gateway_PPEC_Plugin::needs_shipping() ) {
299
+ return;
300
+ }
301
+
302
  ?>
303
  <h3><?php _e( 'Shipping details', 'woocommerce-gateway-paypal-express-checkout' ); ?></h3>
304
  <?php
includes/class-wc-gateway-ppec-client.php CHANGED
@@ -303,7 +303,7 @@ class WC_Gateway_PPEC_Client {
303
  'PAYMENTREQUEST_0_SHIPPINGAMT' => $details['shipping'],
304
  'PAYMENTREQUEST_0_TAXAMT' => $details['order_tax'],
305
  'PAYMENTREQUEST_0_SHIPDISCAMT' => $details['ship_discount_amount'],
306
- 'NOSHIPPING' => 0,
307
  )
308
  );
309
 
@@ -840,10 +840,10 @@ class WC_Gateway_PPEC_Client {
840
  'order_id' => $order_id,
841
  'order_key' => $order_key,
842
  ) ),
843
- 'NOSHIPPING' => 0,
844
  );
845
 
846
- if ( ! empty( $details['shipping_address'] ) ) {
847
  $params = array_merge(
848
  $params,
849
  $details['shipping_address']->getAddressParams( 'PAYMENTREQUEST_0_SHIPTO' )
303
  'PAYMENTREQUEST_0_SHIPPINGAMT' => $details['shipping'],
304
  'PAYMENTREQUEST_0_TAXAMT' => $details['order_tax'],
305
  'PAYMENTREQUEST_0_SHIPDISCAMT' => $details['ship_discount_amount'],
306
+ 'NOSHIPPING' => WC_Gateway_PPEC_Plugin::needs_shipping() ? 0 : 1,
307
  )
308
  );
309
 
840
  'order_id' => $order_id,
841
  'order_key' => $order_key,
842
  ) ),
843
+ 'NOSHIPPING' => WC_Gateway_PPEC_Plugin::needs_shipping() ? 0 : 1,
844
  );
845
 
846
+ if ( WC_Gateway_PPEC_Plugin::needs_shipping() && ! empty( $details['shipping_address'] ) ) {
847
  $params = array_merge(
848
  $params,
849
  $details['shipping_address']->getAddressParams( 'PAYMENTREQUEST_0_SHIPTO' )
includes/class-wc-gateway-ppec-plugin.php CHANGED
@@ -372,4 +372,22 @@ class WC_Gateway_PPEC_Plugin {
372
 
373
  return array_merge( $plugin_links, $links );
374
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
375
  }
372
 
373
  return array_merge( $plugin_links, $links );
374
  }
375
+
376
+ /**
377
+ * Check if shipping is needed for PayPal.
378
+ *
379
+ * @since 1.4.1
380
+ * @version 1.4.1
381
+ *
382
+ * @return bool
383
+ */
384
+ public static function needs_shipping() {
385
+ // In case there are no shipping methods defined, we still return true (see #249)
386
+ if ( ! wc_shipping_enabled() || 0 === wc_get_shipping_method_count( true ) ) {
387
+ return true;
388
+ }
389
+
390
+ // Otherwise go through all items and see if they require shipping (e.g. virtual items will not, see #286)
391
+ return WC()->cart->needs_shipping();
392
+ }
393
  }
readme.txt CHANGED
@@ -3,7 +3,7 @@ Contributors: automattic, woothemes, akeda, dwainm, royho, allendav, slash1andy,
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: 4.7
6
- Stable tag: 1.4.0
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
@@ -85,6 +85,10 @@ https://gist.github.com/mikejolley/ad2ecc286c9ad6cefbb7065ba6dfef48
85
 
86
  == Changelog ==
87
 
 
 
 
 
88
  = 1.4.0 =
89
  * Tweak - Use shipping discount instead of tax when adjustment negative.
90
  * Fix - Cannot process refunds on "authorize" transactions.
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: 4.7
6
+ Stable tag: 1.4.1
7
  License: GPLv3
8
  License URI: http://www.gnu.org/licenses/gpl-3.0.html
9
 
85
 
86
  == Changelog ==
87
 
88
+ = 1.4.1 =
89
+ * Fix - Properly calculate whether Billing phone is required or not.
90
+ * Fix - Set NOSHIPPING based on product shipping requiredness (e.g. virtual products do not need shipping, etc)
91
+
92
  = 1.4.0 =
93
  * Tweak - Use shipping discount instead of tax when adjustment negative.
94
  * Fix - Cannot process refunds on "authorize" transactions.
woocommerce-gateway-paypal-express-checkout.php CHANGED
@@ -3,7 +3,7 @@
3
  * Plugin Name: WooCommerce PayPal Express Checkout Gateway
4
  * Plugin URI: https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/
5
  * Description: A payment gateway for PayPal Express Checkout (https://www.paypal.com/us/webapps/mpp/express-checkout).
6
- * Version: 1.4.0
7
  * Author: WooCommerce
8
  * Author URI: https://woocommerce.com
9
  * Copyright: © 2017 WooCommerce / PayPal.
@@ -25,7 +25,7 @@ if ( ! defined( 'ABSPATH' ) ) {
25
  exit; // Exit if accessed directly
26
  }
27
 
28
- define( 'WC_GATEWAY_PPEC_VERSION', '1.4.0' );
29
 
30
  /**
31
  * Return instance of WC_Gateway_PPEC_Plugin.
3
  * Plugin Name: WooCommerce PayPal Express Checkout Gateway
4
  * Plugin URI: https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/
5
  * Description: A payment gateway for PayPal Express Checkout (https://www.paypal.com/us/webapps/mpp/express-checkout).
6
+ * Version: 1.4.1
7
  * Author: WooCommerce
8
  * Author URI: https://woocommerce.com
9
  * Copyright: © 2017 WooCommerce / PayPal.
25
  exit; // Exit if accessed directly
26
  }
27
 
28
+ define( 'WC_GATEWAY_PPEC_VERSION', '1.4.1' );
29
 
30
  /**
31
  * Return instance of WC_Gateway_PPEC_Plugin.