Forked from quangmai911/blocksy-add-quantity-to-archive-cards.php
Created
July 10, 2024 22:16
-
-
Save racmanuel/da23b2c1aca6337bfd40a24f6cdd7953 to your computer and use it in GitHub Desktop.
Blocksy Add Quantity to Archive Cards
This file contains 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 | |
add_filter( 'woocommerce_loop_add_to_cart_link', function ( $html, $product ) { | |
if ( is_user_logged_in() && is_shop() && $product && $product->is_type( 'simple' ) && $product->is_purchasable() && $product->is_in_stock() && ! $product->is_sold_individually() ) { | |
$html = '<form action="' . esc_url( $product->add_to_cart_url() ) . '" class="cart" method="post" enctype="multipart/form-data"><div class="ct-cart-actions">'; | |
$html .= woocommerce_quantity_input( array(), $product, false ); | |
$html .= '<button type="submit" class="single_add_to_cart_button button alt" name="add-to-cart" value="' . $product->get_id() . '">' . esc_html( $product->add_to_cart_text() ) . '</button>'; | |
$html .= '</div></form>'; | |
} | |
return $html; | |
}, 10, 2 ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment