这是一个新问题,其要求与以下答案相同: Checking that one of multiple mandatory products categories are in cart
但它似乎对我不起作用,我在这一行上收到错误:
if( !WC()->cart->is_empty() && ( is_cart() || is_product_category(
$categories_needed[0] || is_product_category( $categories_needed[1] ) )
){
我收到意外
的错误{
感谢任何帮助。
答案 0 :(得分:1)
只有两个小错误:
1)$ perl app.pl get /export
[Fri Apr 20 18:43:20 2018] [debug] Your secret passphrase needs to be changed
[Fri Apr 20 18:43:20 2018] [debug] GET "/export"
[Fri Apr 20 18:43:20 2018] [debug] Routing to a callback
[Fri Apr 20 18:43:20 2018] [debug] Rendering template "export.html.ep" from DATA section
[Fri Apr 20 18:43:20 2018] [debug] 200 OK (0.002478s, 403.551/s)
<div>
bar: <p/>
baz: baz<p/>
</div>
末尾缺少;
,所以在此更新的代码中:
return $categories
2)// Function that define the mandatory product category
function your_mandatory_category_slug(){
// DEFINE HERE the 2 SLUGs of the needed product categories
$categories = array('cxsuite-download-option','cxsuite-hosted-option');
return $categories; // <== HERE
}
中缺少结束)
,因此在此更新的代码中
is_product_category( $categories_needed[0]
现在它应该没有错误......