Created
May 14, 2020 00:40
-
-
Save nfmohit/80fefce7ed2463e827194bf577eaa52e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| if ( ! function_exists( 'woocommerce_template_loop_add_to_cart' ) ) { | |
| function woocommerce_template_loop_add_to_cart( $args = array() ) { | |
| global $product; | |
| if ( !$product->is_in_stock() ) { | |
| echo '<a href="' . get_permalink() . '" class="button">Out of Stock</a>'; | |
| } else { | |
| $defaults = array( | |
| 'quantity' => 1, | |
| 'class' => implode( ' ', array_filter( array( | |
| 'button', | |
| 'product_type_' . $product->product_type, | |
| $product->is_purchasable() && $product->is_in_stock() ? 'add_to_cart_button' : '', | |
| $product->supports( 'ajax_add_to_cart' ) ? 'ajax_add_to_cart' : '' | |
| ) ) ) | |
| ); | |
| $args = apply_filters( 'woocommerce_loop_add_to_cart_args', wp_parse_args( $args, $defaults ), $product ); | |
| wc_get_template( 'loop/add-to-cart.php', $args ); | |
| } | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment