Do you know how to add the “Add to Cart” button in Divi shop pages?

by Jun 11, 2020Projects, Tutorials0 comments

How to add “Add to Cart” button in Divi shop pages

How to add the “Add to Cart” button in Divi shop pages

 

Hi, my dear Divi maniacs,

today working on an e-commerce based on Divi and Woocommerce I needed to answer to this question:

“How can I add the “Add to Cart” button in Divi shop pages?”

 

Unfortunately, Divi have not a button that lets us adding the cart icon or the button “add to cart”, so we have to find a solution.

Google, as a rule, give me a great hand.
In fact, looking around the web I found this very easy way to solve this problem.

To use this solution you need your website is based on a child-theme (based on Divi, of course). If you have it you have simply to open the file functions.php and copy and paste the following code:

// Add "Add to Cart" buttons into a page displaying shop loop
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 20 );

Starting this moment your shop page show you a beautiful button “add to Cart“.

Fine or not?

See you soon!