Only display add_payment_method() when logged in

Part of #3396
This commit is contained in:
thenbrent 2013-11-01 14:11:25 -07:00
parent ca01d7b1a5
commit 4f825eb36e
1 changed files with 17 additions and 7 deletions

View File

@ -209,18 +209,28 @@ class WC_Shortcode_Checkout {
private static function add_payment_method() {
global $woocommerce;
do_action( 'before_woocommerce_add_payment_method' );
if ( ! is_user_logged_in() ) {
wc_add_message( __( 'Add a new payment method.', 'woocommerce' ) );
wp_safe_redirect( get_permalink( woocommerce_get_page_id( 'myaccount' ) ) );
exit();
wc_print_messages();
} else {
// Add payment method form
woocommerce_get_template( 'checkout/form-add-payment-method.php' );
do_action( 'before_woocommerce_add_payment_method' );
wc_print_messages();
wc_add_message( __( 'Add a new payment method.', 'woocommerce' ) );
wc_print_messages();
// Add payment method form
woocommerce_get_template( 'checkout/form-add-payment-method.php' );
wc_print_messages();
do_action( 'after_woocommerce_add_payment_method' );
}
do_action( 'after_woocommerce_add_payment_method' );
}
/**