Skip to content

Instantly share code, notes, and snippets.

@elitteral
Created February 26, 2015 04:01
Show Gist options
  • Star 9 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save elitteral/a655d4b078d34ad23006 to your computer and use it in GitHub Desktop.
Save elitteral/a655d4b078d34ad23006 to your computer and use it in GitHub Desktop.
Cause Divi to show the Add To Cart buttons on the Shop page when using the WooCommerce plugin
/*
* Divi WordPress Theme and WooCommerce plugin
* Make the Add To Cart buttons appear on the WooCommerce shop page.
*/
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 20 );
@knowing8
Copy link

That worked putting in theme functions.php . thanks!

@cdenders
Copy link

This does not seem to work for Divi 3.0. Any other code?

@accessomnath
Copy link

after add the code...why 5 come

@crgo
Copy link

crgo commented Nov 6, 2016

how do you remove that 5 number

@rendythamrin
Copy link

when mouse pointer goes at button, it show 5 instead of >

@divipro
Copy link

divipro commented Dec 4, 2016

I added this to CSS in Divi 3.0+...

(added this on shop pages with variations) li.product .variations_form.cart div.variations { display: none; }

(added to child theme css)
div.related.products li.product .variations_form.cart div.variations { display: none; }

.comment-reply-link:hover:after, .woocommerce a.button.alt:hover:after, .woocommerce-page a.button.alt:hover:after, .woocommerce button.button.alt:hover:after, .woocommerce-page button.button.alt:hover:after, .woocommerce input.button.alt:hover:after, .woocommerce-page input.button.alt:hover:after, .woocommerce #respond input#submit.alt:hover:after, .woocommerce-page #respond input#submit.alt:hover:after, .woocommerce #content input.button.alt:hover:after, .woocommerce-page #content input.button.alt:hover:after, .woocommerce a.button:hover:after, .woocommerce-page a.button:hover:after, .woocommerce button.button:hover:after, .woocommerce-page button.button:hover:after, .woocommerce input.button:hover:after, .woocommerce-page input.button:hover:after, .woocommerce #respond input#submit:hover:after, .woocommerce-page #respond input#submit:hover:after, .woocommerce #content input.button:hover:after, .woocommerce-page #content input.button:hover:after { display: none; }

.woocommerce a.button:hover, .woocommerce-page a.button:hover { padding: 0.3em 1em !important; }

.woocommerce ul.products li.product .button { margin-top: 1em; margin: auto !important; position: relative; text-align: center; display: table !important; }

.woocommerce ul.products li.product .price { margin-bottom: 1em !important; }

@tiagocordeiro
Copy link

This solved the problem of 5 in place of >

.woocommerce .button::after {
font-family: "ETmodules";
}

@Garconis
Copy link

FWIW, this code works fine for me with Divi 3.0.X without any modifications. https://gyazo.com/8de0ce8efb8b97997d76241dfccd31f2

@JLCHAVES13
Copy link

JLCHAVES13 commented Apr 6, 2017

It worked perfectly, using the code in functions.php
Now I just need to figure out how to center and align the buttons = (
I am using Divi 3.0

@bethf
Copy link

bethf commented Jun 9, 2017

Exactly what I needed! THANK YOU!

@sephmilanes
Copy link

i added this code to our site "add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 20 );" but it shows different.. check my shop page https://www.ampalaya.ph/shop/

@alexanderbiscajin
Copy link

Some of the store owners find difficulty while removing the add to cart buttons. For any shop page you can remove add to cart button through adding following hooks to woocommerce.php (located wp-content/plugins/woocommerce)
function WpBlog() {
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart');
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_add_to_cart');
return WooCommerce::instance();
}
After refreshing you can see that the button has been removed from the page. If you still see that the button hasn't been removed then you can view this as reference https://www.wpblog.com/add-to-cart-button-in-woocommerce-store/

@gonzalo-novak
Copy link

You are my hero <3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment