Website Building » WooCommerce » How to Add a Buy Now Button in WooCommerce Without Plugin?

How to Add a Buy Now Button in WooCommerce Without Plugin?

Last updated on October 1, 2022 @ 1:27 pm

Adding a buy now button in WooCommerce without a plugin is actually quite simple. All you need to do is edit the code for your product page template.

The product page template is located in the WooCommerce folder of your theme. If you’re not sure which file is the product page template, you can always look for the folder named “single-product” and open the file named “single-product.php”.

Once you have located the product page template, you will need to edit the code in two places. The first place is at the very top of the file. You will see a line of code that says:

You will need to replace that line of code with the following:

The second place you will need to edit the code is near the bottom of the file. There is a line of code that says:

PRO TIP: Adding a buy now button in WooCommerce without a plugin is not recommended as it can cause errors and conflicts on your website.

is_type( ‘simple’ ) && $product->get_sku() ) : ?>

get_sku() ) ? $sku : esc_html__( ‘N/A’, ‘woocommerce’ ); ?>.

‘; ?>.

:.

get weight() ); ?>.

.

;

:.

get dimensions( false ), true ); ?>.

Morgan Bash

Morgan Bash

Technology enthusiast and Co-Founder of Women Coders SF.