小编Pat*_*our的帖子

WooCommerce 可变产品通知问题 - 请选择产品选项

我正在建立一个电子商务网站。我在使用 WooCommerce Variable Product时遇到了一些问题。

\n

“添加到购物车”按钮适用于简单产品,但不适用于可变产品。它给出了一个"Please choose product options\xe2\x80\xa6"通知。

\n

我到处寻找并尝试了网上的一些建议,但没有一个起作用。所以我查看了 WooCommerce 源文件:class-wc-form-handler.php.

\n

在函数中add_to_cart_handler_variable

\n
function add_to_cart_handler_variable( $product_id ) {\n    $adding_to_cart     = wc_get_product( $product_id );\n    $variation_id       = empty( $_REQUEST['variation_id'] ) ? '' : absint( $_REQUEST['variation_id'] );\n    $quantity           = empty( $_REQUEST['quantity'] ) ? 1 : wc_stock_amount( $_REQUEST['quantity'] );\n    $missing_attributes = array();\n    $variations         = array();\n    $attributes         = $adding_to_cart->get_attributes();\n    $variation          = wc_get_product( $variation_id );\n...\nif ( $missing_attributes ) {\n        wc_add_notice( sprintf( _n( '%s is a required …
Run Code Online (Sandbox Code Playgroud)

php wordpress product woocommerce product-variations

6
推荐指数
1
解决办法
2万
查看次数