/* Botón de añadir al carrito en tienda */
add_action( ‘woocommerce_after_shop_loop_item’, ‘woocommerce_template_loop_add_to_cart’, 20 );
//agregamos lac cantidades antes del boton
//Agregamos código HTML
add_filter( ‘woocommerce_loop_add_to_cart_link’, ‘dcms_add_quantity_field’, 10, 2 );
function dcms_add_quantity_field($html, $product) {
if($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”>’;
$html.= woocommerce_quantity_input(array(),$product,false);
$html.='<button type=”submit” data-quantity=”1″ data-product_id=”‘.$product->get_id().'” class=”button alt ajax_add_to_cart add_to_cart_button product_type_simple”>’. esc_html($product->add_to_cart_text()).'</button>’;
$html.='</form>’;
}
return$html;
}
//Agreamos código javascript
add_action( ‘init’, ‘dcms_quantity_change’ );
function dcms_quantity_change() {
wc_enqueue_js(‘
(function( $ ) {
$(“form.cart”).on(“change”, “input.qty”, function() {
$(this.form).find(“[data-quantity]”).attr(“data-quantity”, this.value);
});
})( jQuery );
‘);
}
6 comentarios
site here
Pretty! This was a really wonderful article. Thank you for supplying these details.
porn
Excellent post. I certainly love this website. Keep it up!
Y2MATE
This website was… how do you say it? Relevant!! Finally I have found something which helped me. Thank you!
porn
Excellent article! We are linking to this particularly great post on our website. Keep up the great writing.
browse around this site
This site certainly has all of the info I wanted concerning this subject and didn’t know who to ask.
porn
Saved as a favorite, I like your site!