diff --git a/assets/js/frontend/tokenization-form.js b/assets/js/frontend/tokenization-form.js index 05dbda2d449..8cb7dc684b0 100644 --- a/assets/js/frontend/tokenization-form.js +++ b/assets/js/frontend/tokenization-form.js @@ -1,4 +1,3 @@ -/* global woocommerceTokenizationParams */ ( function( $, data ) { $( function() { var wcTokenizationForm = (function() { @@ -10,7 +9,7 @@ this.onTokenChange = function() { if ( 'new' === $( this ).val() ) { $wcTokenizationForm.showForm(); - $wcTokenizationForm.showSaveNewCheckboxForLoggedInOnly(); + $wcTokenizationForm.showSaveNewCheckbox(); } else { $wcTokenizationForm.hideForm(); $wcTokenizationForm.hideSaveNewCheckbox(); @@ -31,8 +30,8 @@ $( ':input.wc-gateway-payment-token:last', $target ).prop( 'checked', true ); } - // Don't show the "use new" radio button if we are a guest or only have one method.. - if ( 0 === $target.data( 'count' ) || ! data.userLoggedIn ) { + // Don't show the "use new" radio button if we only have one method.. + if ( 0 === $target.data( 'count' ) ) { $( '.wc-payment-form-new-checkbox-wrap', $target ).hide(); } @@ -56,14 +55,6 @@ $( '.wc-new-payment-method-wrap', $formWrap ).hide(); }; - this.showSaveNewCheckboxForLoggedInOnly = function() { - if ( data.userLoggedIn ) { - $wcTokenizationForm.showSaveNewCheckbox(); - } else { - $wcTokenizationForm.hideSaveNewCheckbox(); - } - }; - // When a radio button is changed, make sure to show/hide our new CC info area $( ':input.wc-gateway-payment-token', $target ).change( this.onTokenChange ); @@ -85,4 +76,4 @@ } ); } ); }); -})( jQuery, woocommerceTokenizationParams ); +})( jQuery ); diff --git a/includes/abstracts/abstract-wc-payment-gateway.php b/includes/abstracts/abstract-wc-payment-gateway.php index d431e60b69f..392f62e50b8 100644 --- a/includes/abstracts/abstract-wc-payment-gateway.php +++ b/includes/abstracts/abstract-wc-payment-gateway.php @@ -359,21 +359,30 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { return apply_filters( 'woocommerce_payment_gateway_supports', in_array( $feature, $this->supports ) ? true : false, $feature, $this ); } + /** + * Core credit card form which gateways can used if needed. Deprecated - inheirt WC_Payment_Gateway_CC instead. + * @param array $args + * @param array $fields + */ + public function credit_card_form( $args = array(), $fields = array() ) { + _deprecated_function( 'credit_card_form', '2.6', 'WC_Payment_Gateway_CC->form' ); + $cc_form = new WC_Payment_Gateway_CC; + $cc_form->id = $this->id; + $cc_form->supports = $this->supports; + $cc_form->form(); + } + /** * Enqueues our tokenization script to handle some of the new form options. * @since 2.6.0 */ public function tokenization_script() { - $suffix = defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min'; wp_enqueue_script( 'woocommerce-tokenization-form', - plugins_url( '/assets/js/frontend/tokenization-form' . $suffix . '.js', WC_PLUGIN_FILE ), + plugins_url( '/assets/js/frontend/tokenization-form' . ( defined( 'SCRIPT_DEBUG' ) && SCRIPT_DEBUG ? '' : '.min' ) . '.js', WC_PLUGIN_FILE ), array( 'jquery' ), WC()->version ); - wp_localize_script( 'woocommerce-tokenization-form', 'woocommerceTokenizationParams', array( - 'userLoggedIn' => (bool) is_user_logged_in(), - ) ); } /** @@ -477,17 +486,4 @@ abstract class WC_Payment_Gateway extends WC_Settings_API { $html .= ''; return $html; } - - /** - * Core credit card form which gateways can used if needed. Deprecated - inheirt WC_Payment_Gateway_CC instead. - * @param array $args - * @param array $fields - */ - public function credit_card_form( $args = array(), $fields = array() ) { - _deprecated_function( 'credit_card_form', '2.6', 'WC_Payment_Gateway_CC->form' ); - $cc_form = new WC_Payment_Gateway_CC; - $cc_form->id = $this->id; - $cc_form->supports = $this->supports; - $cc_form->form(); - } }