Skip to content

Early-bird lifetime licence: $199 once, for the first 200 buyers only. See the offer

Skip the cart and go straight to checkout in WooCommerce without a plugin

Send shoppers straight to the checkout with one Snipfire snippet, and remove checkout fields with another. Direct Checkout for WooCommerce offers more options; here is the honest comparison.

What Direct Checkout for WooCommerce does

Direct Checkout for WooCommerce skips the cart page by sending shoppers to the checkout, with more options to simplify the checkout. The plugin on WordPress.org

What the snippet does the same

  • Add to cart takes customers straight to the checkout instead of the cart, on product pages and shop lists.
  • The second snippet removes checkout fields you don't need. By default it removes company name and the second address line.

What's different

  • To send every shop-list button to the checkout, the snippet switches off adding in the background, so the page reloads. Product blocks with their own add-to-cart button keep adding in the background.
  • Field removal applies to the classic checkout only, and you edit the list of fields in the code. The plugin removes fields from a settings screen.
  • The plugin has more options, such as changing the add to cart text, removing the coupon form and adding a quick purchase button (some of these are in its paid version).

When to keep the plugin Keep the plugin if you want to manage the checkout from a settings screen or use its quick purchase button.

The snippet: Go straight to checkout

Add to cart takes customers straight to the checkout instead of the cart. Suits shops that mostly sell one product at a time.

PHP
<?php

// Shop lists use normal links instead of adding in the background, so every
// add-to-cart button can go on to the checkout.
add_filter( 'option_woocommerce_enable_ajax_add_to_cart', static fn() => 'no' );
add_filter( 'option_woocommerce_cart_redirect_after_add', static fn() => 'yes' );
add_filter( 'woocommerce_add_to_cart_redirect', static fn() => wc_get_checkout_url(), 20 );

Notes, where it runs and what it was tested with

The snippet: Remove checkout fields you don’t need

Removes company name and the second address line from the checkout. Edit the list to remove other fields.

PHP
<?php

// Field names: billing_company, billing_address_2, billing_state,
// billing_phone, shipping_company, shipping_address_2, shipping_state...
$remove = array( 'billing_company', 'billing_address_2', 'shipping_company', 'shipping_address_2' );

add_filter(
	'woocommerce_checkout_fields',
	static function ( $fields ) use ( $remove ) {
		foreach ( $remove as $name ) {
			$group = strtok( $name, '_' );
			unset( $fields[ $group ][ $name ] );
		}
		return $fields;
	},
	20
);

Notes, where it runs and what it was tested with

Switching from the plugin

  1. Install the snippet in Snipfire (it arrives switched off).
  2. Deactivate Direct Checkout for WooCommerce.
  3. Switch the snippet on. Snipfire checks the code and test-loads your site first.
  4. Check the page it affects, then delete the plugin.

Move your snippets over this afternoon.

Importing changes nothing until you switch over, and your old shortcodes keep working.