Last active
May 10, 2020 11:56
-
-
Save Oscar-Abad-Folgueira/d750d668908fd84fb520234cb4aa56f5 to your computer and use it in GitHub Desktop.
Establecer cantidad de compra de productos en WooCommerce de 2 en 2
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 | |
/** | |
* @snippet Establecer cantidad de compra de productos en WooCommerce de 2 en 2 | |
* @author Oscar Abad Folgueira | |
* @author_url https://www.oscarabadfolgueira.com | |
* @snippet_url https://www.oscarabadfolgueira.com/establecer-que-solo-se-puedan-comprar-cantidad-de-2-en-2-en-woocommerce/ | |
*/ | |
add_filter( 'woocommerce_quantity_input_args', 'woocommerce_quanty_imput_step', 10, 2 ); // Simple products | |
function woocommerce_quanty_imput_step( $args, $product ) { | |
if ( is_singular( 'product' ) ) { | |
$args['input_value'] = 2; // Valor de comienzo | |
} | |
$args['step'] = 2; // de 2 en 2. | |
$args['min_value'] = 2; // Valor mínimo de cantidad | |
return $args; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment