admin管理员组

文章数量:1336293

Will please someone help me why this happens. Firstly here is my code.

add_action( 'woocommerce_after_add_to_cart_form', 'sione_enquiry_button' );
add_action('woocommerce_cart_actions', 'sione_enquiry_button_new');
function sione_enquiry_button() {
if(!is_product()){
return;
}


if (has_term( 'blue-block-frames', 'product_cat' )) {
    ?>
    <input disabled style="padding: 5px 20px;background: #193670!important;border: 0!important;color: white!important;" type="button" id="enquiry-button" class="btn enquiry-button" value="<?php echo __( 'Whatsapp your prescription to +918328120536 after purchase', 'orchid' ); ?>" />

    <?php
    } else {
    ?>
    <input style="padding: 5px 20px;background: #193670!important;border: 0!important;color: white!important;" type="button" id="enquiry-button" class="btn enquiry-button" value="<?php echo __( 'Send Enquiry for Wholesale Price', 'orchid' ); ?>" />

    <?php
    }
}

function sione_enquiry_button_new() {
if(is_cart()) {
$check = false;
// check each cart item for our category
foreach ( WC()->cart->get_cart() as $cart_item_key => $cart_item ) {

    $product = $cart_item['data'];

    // replace 'membership' with your category's slug
    if ( has_term( 'blue-block-frames', 'product_cat', $product->id ) ) {
$check= true;
    }
}
if($check == true) {
    ?>
    <input disabled style="padding: 5px 20px;background: #193670!important;border: 0!important;color: white!important;" type="button" id="enquiry-button" class="btn enquiry-button" value="<?php echo __( 'Whatsapp your prescription to +918328120536 after purchase', 'orchid' ); ?>" />

    <?php
} else {
    ?>
    <input style="padding: 5px 20px;background: #193670!important;border: 0!important;color: white!important;" type="button" id="enquiry-button" class="btn enquiry-button" value="<?php echo __( 'Send Enquiry for Wholesale Price', 'orchid' ); ?>" />

    <?php
}
}
}

Will someone please tell me why else statement is showing even else is false.

本文标签: categoriesIn ifelse conditionthe else statement shows even if if statement is correct