Snippets: Display Static WooCommerce Add to Cart Button on Mobile

By default the Total theme displays an add to cart button when hovering over the product image for product entries. If you wanted to display a static button mobile only it's possible with a little code. The following code re-adds the static button and hides it on all devices over 1024px

// Re-add the static add to cart button.
function my_add_product_mobile_add_to_cart() {
	add_action( 'woocommerce_after_shop_loop_item', 'my_custom_product_add_to_cart', 10 );
add_action( 'init', 'my_add_product_mobile_add_to_cart' );

// Custom function for displaying the add to cart button mobile only.
function my_custom_product_add_to_cart() {
	echo '<div class="wpex-lg-hidden">';
	echo '</div>';
All PHP snippets should be added via a child theme's functions.php file or via the Code Snippets Plugin (or alternative plugin)