0

我想要以下函数来检查多个产品 ID !==(1427、1428、1429)。最好的方法是什么?

谢谢你。

//add multistep
add_action('wapf_before_wrapper', 'wapf_before_wrapper');
function wapf_before_wrapper($product) {
    if($product->get_id() !==1427)
                return;
    ?>
    <div class="wapf-progress">
        <div class="wapf-progress-bar"></div>
        <div class="wapf-progress-steps"></div>
    </div>
    <?php
}

add_action('wapf_before_product_totals', 'wapf_before_product_totals');
function wapf_before_product_totals($product){
    if($product->get_id() !==1427)
                return;
    ?>
    <div class="wapf_step_buttons">
        <button class="button wapf_btn_prev" style="display:none">Previous</button>
        <button class="button wapf_btn_next">Next</button>
    </div>
    <?php
} 
//end multistep
4

1 回答 1

0

你的问题是关于 php 还是 JavaScript?

问题标题询问关于 JavaScript,我将使用它

if(![1427, 1428, 1429].includes(product.id)) { }

但是你的代码示例是 php,我也不知道,但我相信它有in_array,所以这样的东西可能会起作用

$ids = array(1427, 1428, 1429)
if (in_array($product->get_id(), $ids) { } 
于 2020-07-16T02:33:00.303 回答