[英]woocommerce_quantity_input doesn't work in add to cart loop
I need a quantity selection block in the add to cart loop on the product list page in woocommerce. 在woocommerce的产品列表页面上的添加到购物车循环中,我需要一个数量选择块。 Woocommerce codex has a page which allows me to do it by basically putting this block of code instead of the existing one:
Woocommerce Codex有一个页面,使我可以通过基本上放置此代码块而不是现有代码块来执行此操作:
<form action="<?php echo esc_url( $product->add_to_cart_url() ); ?>" class="cart" method="post" enctype='multipart/form-data'>
<?php woocommerce_quantity_input(); ?>
<button type="submit" class="button alt"><?php echo $label; ?></button>
</form>
However, that form doesn't add to my current AJAX setup and other nice tricks that come with my original add to cart button. 但是,该表单不会添加到我当前的AJAX设置中,也不会添加到我原来的“添加到购物车”按钮中的其他不错的技巧。 This is the original code of the add to cart button, which works like i want it, except for missing the quantity input:
这是“添加到购物车”按钮的原始代码,其工作方式与我想要的一样,只是缺少输入的数量:
<?php
/**
* Loop Add to Cart
*
* @author WooThemes
* @package WooCommerce/Templates
* @version 2.1.0
*/
if ( ! defined( 'ABSPATH' ) ) exit; // Exit if accessed directly
global $product, $jckqv;
$jckqv->displayBtn($product->id);
echo '<div class="product-buttons">';
echo apply_filters( 'woocommerce_loop_add_to_cart_link',
sprintf( '<a href="%s" rel="nofollow" data-product_id="%s" data-product_sku="%s" class="button %s product_type_%s">%s</a>',
esc_url( $product->add_to_cart_url() ),
esc_attr( $product->id ),
esc_attr( $product->get_sku() ),
$product->is_purchasable() ? 'add_to_cart_button' : '',
esc_attr( $product->product_type ),
esc_html( $product->add_to_cart_text() )
),
$product );
echo do_shortcode('[yith_compare_button]');
echo do_shortcode('[yith_wcwl_add_to_wishlist]');
echo '</div>';
I need to somehow put the woocommerce_quantity_input in this code, to retain the current functionality, but to add the quantity input. 我需要以某种方式将woocommerce_quantity_input放入此代码中,以保留当前功能,但要添加数量输入。 I tried to do it in many various ways, but unfortunately my PHP skills lack.
我试图以多种方式做到这一点,但是不幸的是我的PHP技能缺乏。 Please help.
请帮忙。 Thank you
谢谢
For anybody who might still need to use this 对于可能仍需要使用此功能的任何人
<?php woocommerce_quantity_input(); ?>
You need to echo it. 您需要回显它。 As easy as that
那样简单
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.