0
votes

I've been trying to add a filter to my woocommerce code to prevent the form from sending the customer email address to paypal. (Im using paypal standard). Supposedly this will cause the credit card form to be the default display instead of the 'sign in to paypal' option.

I've found this code here: Paypal Payment Standard default enter card details that should do this, but i'm unsure where to place that code. Here is my /templates/checkout/form-checkout.php which is not working:

<form name="checkout" method="post" class="checkout woocommerce-checkout" action="<?php echo esc_url( $get_checkout_url ); ?>" enctype="multipart/form-data">

	<?php if ( sizeof( $checkout->checkout_fields ) > 0 ) : ?>

		<?php do_action( 'woocommerce_checkout_before_customer_details' ); ?>

		<div class="col2-set" id="customer_details">
			<div class="col-1">
				<?php do_action( 'woocommerce_checkout_billing' ); ?>
			</div>

			<div class="col-2">
				<?php do_action( 'woocommerce_checkout_shipping' ); ?>
			</div>
		</div>

                <?php function smw_woo_paypal_args($args) {
                    $args['email'] = '';
                    return $args;
                } 
                add_filter( 'woocommerce_paypal_args', 'smw_woo_paypal_args', 99);
                ?>
		<?php do_action( 'woocommerce_checkout_after_customer_details' ); ?>

		<h3 id="order_review_heading"><?php _e( 'Your order', 'woocommerce' ); ?></h3>

	<?php endif; ?>

	<div id="order_review" class="woocommerce-checkout-review-order">
		<?php do_action( 'woocommerce_checkout_order_review' ); ?>
	</div>

</form>

Any ideas on where to place this filter?

1

1 Answers

0
votes

Place that filter in your theme's functions.php file. That will make it functional and should leave the email empty as expected.

That said, I don't think that's going to solve your problem. Payments Standard checkout pages are typically cookie based, and if any user has signed in to an account on the browser being used, it will assume that any PayPal checkout will be using that account and will default that way.

If you were to clear your browser cache/cookies, or just use a fresh, clean browser, you'd probably see that the guest checkout option is more prominent.

If you were to use the Express Checkout API, though, you can force this more easily. You're using WooCommerce, so checkout PayPal for WooCommerce, which includes Express Checkout and it's free. There are settings specific to enabling the full guest checkout / credit card option built into the plugin.