mardi 25 février 2020

Show div on cart page based on backorder status and time of day

I've written a statement which allows me to echo a DIV on the checkout page based on if the order has backorder products (this works) but i want it to based on the time of the day as well.

Here's my code:

add_action( 'woocommerce_before_checkout_form', 'redpakket_items_checkout_notice' );
function redpakket_items_checkout_notice() {
    $found = false;

    foreach( WC()->cart->get_cart() as $cart_item ) {
        if( $cart_item['data']->is_on_backorder( $cart_item['quantity'] ) ) {
            $found = true;
            break;
        }
    }
    date_default_timezone_set("Europe/Amsterdam");
    if( in_array(date("H"), array("22", "23")) && in_array(date("N"), array("1", "2", "3", "4")) ||  $found) {
        echo '<div>Test</div>';
    }
}

Can anyone tell me what i'm doing wrong here?

Aucun commentaire:

Enregistrer un commentaire