mirror of
https://gh.wpcy.net/https://github.com/mainwp/Code-Snippets-Functions.git
synced 2026-04-30 11:42:22 +08:00
https://stackoverflow.com/questions/77751975/exclude-sold-individually-products-in-woocommerce/77752099
12 lines
432 B
Text
12 lines
432 B
Text
function action_woocommerce_before_add_to_cart_quantity() {
|
|
global $product;
|
|
|
|
// Is a WC product
|
|
if ( is_a( $product, 'WC_Product' ) ) {
|
|
// NOT sold individually.
|
|
if ( ! $product->get_sold_individually() ) {
|
|
echo '<div class="qty">Número de asistentes: </div>';
|
|
}
|
|
}
|
|
}
|
|
add_action( 'woocommerce_before_add_to_cart_quantity', 'action_woocommerce_before_add_to_cart_quantity' );
|