Changeset 1966480
- Timestamp:
- 10/31/2018 01:32:43 PM (7 years ago)
- Location:
- woocommerce-gateway-paypal-express-checkout/trunk
- Files:
-
- 10 edited
-
changelog.txt (modified) (1 diff)
-
includes/abstracts/abstract-wc-gateway-ppec.php (modified) (2 diffs)
-
includes/class-wc-gateway-ppec-cart-handler.php (modified) (7 diffs)
-
includes/class-wc-gateway-ppec-checkout-handler.php (modified) (5 diffs)
-
includes/class-wc-gateway-ppec-client.php (modified) (6 diffs)
-
includes/class-wc-gateway-ppec-settings.php (modified) (2 diffs)
-
includes/class-wc-gateway-ppec-with-spb-addons.php (modified) (1 diff)
-
includes/class-wc-gateway-ppec-with-spb.php (modified) (1 diff)
-
readme.txt (modified) (2 diffs)
-
woocommerce-gateway-paypal-express-checkout.php (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
woocommerce-gateway-paypal-express-checkout/trunk/changelog.txt
r1948167 r1966480 1 1 *** Changelog *** 2 3 = 1.6.5 - 2018-10-31 = 4 * Fix - Truncate the line item descriptions to avoid exceeding PayPal character limits. 5 * Update - WC 3.5 compatibility. 6 * Fix - checkout.js script loading when not needed. 7 * Fix - Missing shipping total and address when starting from checkout page. 2 8 3 9 = 1.6.4 - 2018-09-27 = -
woocommerce-gateway-paypal-express-checkout/trunk/includes/abstracts/abstract-wc-gateway-ppec.php
r1904138 r1966480 124 124 return array( 125 125 'result' => 'success', 126 'redirect' => $checkout->start_checkout_from_ checkout( $order_id, $this->use_ppc ),126 'redirect' => $checkout->start_checkout_from_order( $order_id, $this->use_ppc ), 127 127 ); 128 128 } catch ( PayPal_API_Exception $e ) { … … 135 135 136 136 $checkout_context = array( 137 'start_from' => 'checkout',138 137 'order_id' => $order_id, 139 138 ); -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-cart-handler.php
r1948167 r1966480 137 137 138 138 if ( isset( $_POST['from_checkout'] ) && 'yes' === $_POST['from_checkout'] ) { 139 add_filter( 'woocommerce_cart_needs_shipping', '__return_false' );140 141 139 // Intercept process_checkout call to exit after validation. 142 140 add_action( 'woocommerce_after_checkout_validation', array( $this, 'maybe_start_checkout' ), 10, 2 ); 143 141 WC()->checkout->process_checkout(); 144 142 } else { 145 $this->start_checkout( );143 $this->start_checkout( true ); 146 144 } 147 145 } … … 163 161 if ( empty( $error_messages ) ) { 164 162 $this->set_customer_data( $_POST ); 165 $this->start_checkout( );163 $this->start_checkout( false ); 166 164 } else { 167 165 wp_send_json_error( array( 'messages' => $error_messages ) ); … … 173 171 * Set Express Checkout and return token in response. 174 172 * 173 * @param bool $skip_checkout Whether checkout screen is being bypassed. 174 * 175 175 * @since 1.6.4 176 176 */ 177 protected function start_checkout( ) {177 protected function start_checkout( $skip_checkout ) { 178 178 try { 179 wc_gateway_ppec()->checkout->start_checkout_from_cart( );179 wc_gateway_ppec()->checkout->start_checkout_from_cart( $skip_checkout ); 180 180 wp_send_json_success( array( 'token' => WC()->session->paypal->token ) ); 181 181 } catch( PayPal_API_Exception $e ) { … … 268 268 ?> 269 269 <div class="wcppec-checkout-buttons woo_pp_cart_buttons_div"> 270 <?php if ( 'yes' === $settings->use_spb ) : ?> 270 <?php if ( 'yes' === $settings->use_spb ) : 271 wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' ); ?> 271 272 <div id="woo_pp_ec_button_product"></div> 272 273 <?php else : ?> … … 304 305 <?php endif; ?> 305 306 306 <?php if ( 'yes' === $settings->use_spb ) : ?> 307 <?php if ( 'yes' === $settings->use_spb ) : 308 wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' ); ?> 307 309 <div id="woo_pp_ec_button_cart"></div> 308 310 <?php else : ?> … … 337 339 ?> 338 340 339 <?php if ( 'yes' === $settings->use_spb ) : ?> 341 <?php if ( 'yes' === $settings->use_spb ) : 342 wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' ); ?> 340 343 <p class="woocommerce-mini-cart__buttons buttons wcppec-cart-widget-spb"> 341 344 <span id="woo_pp_ec_button_mini_cart"></span> … … 428 431 429 432 } elseif ( 'yes' === $settings->use_spb ) { 430 wp_ enqueue_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true );431 wp_ enqueue_script( 'wc-gateway-ppec-smart-payment-buttons', wc_gateway_ppec()->plugin_url . 'assets/js/wc-gateway-ppec-smart-payment-buttons.js', array( 'jquery', 'paypal-checkout-js' ), wc_gateway_ppec()->version, true );433 wp_register_script( 'paypal-checkout-js', 'https://www.paypalobjects.com/api/checkout.js', array(), null, true ); 434 wp_register_script( 'wc-gateway-ppec-smart-payment-buttons', wc_gateway_ppec()->plugin_url . 'assets/js/wc-gateway-ppec-smart-payment-buttons.js', array( 'jquery', 'paypal-checkout-js' ), wc_gateway_ppec()->version, true ); 432 435 433 436 $data = array( -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-checkout-handler.php
r1925163 r1966480 706 706 707 707 /** 708 * Handler when buyer is checking out from cart page.708 * Handler when buyer is checking out prior to order creation. 709 709 * 710 710 * @return string Redirect URL. 711 711 */ 712 public function start_checkout_from_cart( ) {712 public function start_checkout_from_cart( $skip_checkout = true ) { 713 713 $settings = wc_gateway_ppec()->settings; 714 714 715 715 $context_args = array( 716 's tart_from' => 'cart',716 'skip_checkout' => $skip_checkout, 717 717 ); 718 718 … … 727 727 728 728 /** 729 * Handler when buyer is checking out from checkout page.729 * Handler when buyer is checking out after order is created (i.e. from checkout page with Smart Payment Buttons disabled). 730 730 * 731 731 * @param int $order_id Order ID. … … 734 734 * @return string Redirect URL. 735 735 */ 736 public function start_checkout_from_ checkout( $order_id, $use_ppc ) {736 public function start_checkout_from_order( $order_id, $use_ppc ) { 737 737 $settings = wc_gateway_ppec()->settings; 738 738 739 739 $context_args = array( 740 's tart_from' => 'checkout',741 'order_id' => $order_id,740 'skip_checkout' => false, 741 'order_id' => $order_id, 742 742 ); 743 743 … … 997 997 * Context args to retrieve SetExpressCheckout parameters. 998 998 * 999 * @type string $start_from Start from 'cart' or 'checkout'. 1000 * @type int $order_id Order ID if $start_from is 'checkout'. 999 * @type int $order_id Order ID if order has been created. 1001 1000 * } 1002 1001 * … … 1005 1004 public function needs_billing_agreement_creation( $args ) { 1006 1005 $needs_billing_agreement = false; 1007 switch ( $args['start_from'] ) { 1008 case 'cart': 1009 if ( class_exists( 'WC_Subscriptions_Cart' ) ) { 1010 $needs_billing_agreement = WC_Subscriptions_Cart::cart_contains_subscription(); 1011 } 1012 break; 1013 case 'checkout': 1014 if ( function_exists( 'wcs_order_contains_subscription' ) ) { 1015 $needs_billing_agreement = wcs_order_contains_subscription( $args['order_id'] ); 1016 } 1017 if ( function_exists( 'wcs_order_contains_renewal' ) ) { 1018 $needs_billing_agreement = ( $needs_billing_agreement || wcs_order_contains_renewal( $args['order_id'] ) ); 1019 } 1020 break; 1006 1007 if ( empty( $args['order_id'] ) ) { 1008 if ( class_exists( 'WC_Subscriptions_Cart' ) ) { 1009 $needs_billing_agreement = WC_Subscriptions_Cart::cart_contains_subscription(); 1010 } 1011 } else { 1012 if ( function_exists( 'wcs_order_contains_subscription' ) ) { 1013 $needs_billing_agreement = wcs_order_contains_subscription( $args['order_id'] ); 1014 } 1015 if ( function_exists( 'wcs_order_contains_renewal' ) ) { 1016 $needs_billing_agreement = ( $needs_billing_agreement || wcs_order_contains_renewal( $args['order_id'] ) ); 1017 } 1021 1018 } 1022 1019 -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-client.php
r1948167 r1966480 228 228 * Context args to retrieve SetExpressCheckout parameters. 229 229 * 230 * @type string $s tart_from Start from 'cart' or 'checkout'.231 * @type int $order_id Order ID if $start_from is 'checkout'.230 * @type string $skip_checkout Whether checking out ahead of store checkout screen. 231 * @type int $order_id Order ID if checking out after order is created. 232 232 * @type bool $create_billing_agreement Whether billing agreement creation 233 233 * is needed after returned from PayPal. … … 240 240 $args, 241 241 array( 242 's tart_from' => 'cart',242 'skip_checkout' => true, 243 243 'order_id' => '', 244 244 'create_billing_agreement' => false, … … 262 262 } 263 263 264 if ( 'checkout' === $args['start_from'] ) { 264 if ( ! $args['skip_checkout'] ) { 265 // Display shipping address sent from checkout page, rather than selecting from addresses on file with PayPal. 265 266 $params['ADDROVERRIDE'] = '1'; 266 267 } … … 289 290 $params['PAYMENTREQUEST_0_CURRENCYCODE'] = get_woocommerce_currency(); 290 291 291 switch ( $args['start_from'] ) { 292 case 'checkout': 293 $details = $this->_get_details_from_order( $args['order_id'] ); 294 break; 295 case 'cart': 296 $details = $this->_get_details_from_cart(); 297 break; 292 if ( ! empty( $args['order_id'] ) ) { 293 $details = $this->_get_details_from_order( $args['order_id'] ); 294 } else { 295 $details = $this->_get_details_from_cart(); 298 296 } 299 297 … … 328 326 $line_item_params = array( 329 327 'L_PAYMENTREQUEST_0_NAME' . $count => $values['name'], 330 'L_PAYMENTREQUEST_0_DESC' . $count => ! empty( $values['description'] ) ? s trip_tags( $values['description']) : '',328 'L_PAYMENTREQUEST_0_DESC' . $count => ! empty( $values['description'] ) ? substr( strip_tags( $values['description'] ), 0, 127 ) : '', 331 329 'L_PAYMENTREQUEST_0_QTY' . $count => $values['quantity'], 332 330 'L_PAYMENTREQUEST_0_AMT' . $count => $values['amount'], … … 351 349 * Context args to retrieve SetExpressCheckout parameters. 352 350 * 353 * @type string $start_from Start from 'cart' or 'checkout'.354 * @type int $order_id Order ID if $start_from is 'checkout'.355 351 * @type bool $create_billing_agreement Whether billing agreement creation 356 352 * is needed after returned from PayPal. -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-settings.php
r1904138 r1966480 184 184 _deprecated_function( __METHOD__, '1.2.0', 'WC_Gateway_PPEC_Client::get_set_express_checkout_params' ); 185 185 186 return wc_gateway_ppec()->client->get_set_express_checkout_params( array( 's tart_from' => 'cart') );186 return wc_gateway_ppec()->client->get_set_express_checkout_params( array( 'skip_checkout' => true ) ); 187 187 } 188 188 … … 192 192 // Still missing order_id in args. 193 193 return wc_gateway_ppec()->client->get_set_express_checkout_params( array( 194 's tart_from' => 'checkout',194 'skip_checkout' => false, 195 195 ) ); 196 196 } -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-with-spb-addons.php
r1904138 r1966480 20 20 */ 21 21 public function display_paypal_button() { 22 wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' ); 22 23 ?> 23 24 <div id="woo_pp_ec_button_checkout"></div> -
woocommerce-gateway-paypal-express-checkout/trunk/includes/class-wc-gateway-ppec-with-spb.php
r1904138 r1966480 20 20 */ 21 21 public function display_paypal_button() { 22 wp_enqueue_script( 'wc-gateway-ppec-smart-payment-buttons' ); 22 23 ?> 23 24 <div id="woo_pp_ec_button_checkout"></div> -
woocommerce-gateway-paypal-express-checkout/trunk/readme.txt
r1948167 r1966480 3 3 Tags: ecommerce, e-commerce, commerce, woothemes, wordpress ecommerce, store, sales, sell, shop, shopping, cart, checkout, configurable, paypal 4 4 Requires at least: 4.4 5 Tested up to: 4.9. 66 Stable tag: 1.6. 45 Tested up to: 4.9.8 6 Stable tag: 1.6.5 7 7 License: GPLv3 8 8 License URI: http://www.gnu.org/licenses/gpl-3.0.html … … 102 102 == Changelog == 103 103 104 = 1.6.5 - 2018-10-31 = 105 * Fix - Truncate the line item descriptions to avoid exceeding PayPal character limits. 106 * Update - WC 3.5 compatibility. 107 * Fix - checkout.js script loading when not needed. 108 * Fix - Missing shipping total and address when starting from checkout page. 109 104 110 = 1.6.4 - 2018-09-27 = 105 111 * Fix - Billing address from Checkout form not being passed to PayPal via Smart Payment Button. -
woocommerce-gateway-paypal-express-checkout/trunk/woocommerce-gateway-paypal-express-checkout.php
r1948167 r1966480 4 4 * Plugin URI: https://woocommerce.com/products/woocommerce-gateway-paypal-express-checkout/ 5 5 * Description: A payment gateway for PayPal Checkout (https://www.paypal.com/us/webapps/mpp/paypal-checkout). 6 * Version: 1.6. 46 * Version: 1.6.5 7 7 * Author: WooCommerce 8 8 * Author URI: https://woocommerce.com … … 12 12 * Text Domain: woocommerce-gateway-paypal-express-checkout 13 13 * Domain Path: /languages 14 * WC tested up to: 3. 414 * WC tested up to: 3.5 15 15 * WC requires at least: 2.6 16 16 */ … … 28 28 } 29 29 30 define( 'WC_GATEWAY_PPEC_VERSION', '1.6. 4' );30 define( 'WC_GATEWAY_PPEC_VERSION', '1.6.5' ); 31 31 32 32 /**
Note: See TracChangeset
for help on using the changeset viewer.