WeezFeed

HOW TO CREATE AN “ADD TO CART” BUTTON BELOW PRODUCTS ON YOUR SHOP PAGE

In this post, we are going to show you a super easy way to put Add to cart buttons at the bottom of each product on your shop page.

This does require a little bit of messing around with PHP but you can easily copy and paste the code for this one.

THE FIRST THING YOU WILL NEED TO DO IS TO LOCATE YOUR FUNCTIONS.PHP FILE.

Preferably you should be using a child theme here but if not you can just use your theme’s functions .php file. Just remember by not using a child theme, updates to the theme’s functions .php file will be overwritten when the theme is updated.

There are two methods to find your functions.php file

  1. Fire up your favourite FTP client and navigate to wp-contents / themes / “your-theme”. You will find your functions.php file here.
  2.  You can do this while logged into WordPress. Go to appearance/editor select your theme and then click on functions.php

 

NEXT STEP IS TO COPY THE FOLLOWING CODE TO YOUR FUNCTIONS.PHP FILE.

 

// register add to cart action

function wnc_add_cart_button () {

add_action( 'woocommerce_after_shop_loop_item_title', 'woocommerce_template_loop_add_to_cart', 10 );

}

add_action( 'after_setup_theme', 'wnc_add_cart_button' );

Hit save and go check out your handy work. This makes adding items to your visitor’s carts quicker and ultimately should help you to get more sales.


Thank you for reading this blog and welcome back again! We are happy to see you here.  Did you like this post? Kindly share the post using the buttons below. Drop your comments below in the comment box. 
Comments
Loading...

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More

%d bloggers like this: