【问题标题】:Woocommerce: Add Cart in Single Product page does not workingWoocommerce:在单个产品页面中添加购物车不起作用
【发布时间】:2016-09-09 21:19:21
【问题描述】:

我是 WooCommerce 的新手。

有趣的是,在单个产品页面中添加购物车不起作用(根本没有响应)。但是,当我在商店页面(显示多个产品)时,“添加到购物车”按钮有效。 谁能告诉我这是怎么回事?

网站是这样的:http://dev.myhexa.com/shop/hexa-bluesky-lucky/

最好的问候,

【问题讨论】:

    标签: wordpress woocommerce


    【解决方案1】:

    您的单一产品模板存在根本性错误。 HTML 表单需要提交按钮而不是锚标记。

    放这个

    <input type="submit" data-quantity="1" data-product_id="<?php echo $product->id; ?>" class="single_add_to_cart_button add_to_cart_button  product_type_simple button alt" value="Add to cart" />
    

    而不是这个

    <a data-quantity="1" data-product_id="1162" class="single_add_to_cart_button add_to_cart_button  product_type_simple button alt">Add to cart</a>
    

    您可以在theme-dir/woocommerce/single-product/add-to-cart/simple.php 中找到这些标签

    【讨论】:

    • 谢谢。但是在我替换为此代码后仍然无法正常工作。
    • 哦,我的错,这是type="submit" 不是text。我已经更新了答案。
    • 太棒了!非常感谢! :)
    猜你喜欢
    • 2020-11-15
    • 2018-03-05
    • 2018-06-03
    • 1970-01-01
    • 2018-07-04
    • 1970-01-01
    • 2018-08-15
    • 1970-01-01
    • 2014-11-21
    相关资源
    最近更新 更多