addPreorderNotice( $cart_item ); return '' . $output . '' . $min_cart_date; } /** * @param $cartItem * @param $cartItemKey */ public function addPreorderNotice( $cartItem ) { $product = $cartItem['data']; if ( get_post_meta( $product->get_id(), '_pre_order_date', true ) !== null ) { $availableFrom = new \DateTime( get_post_meta( $product->get_id(), '_pre_order_date', true ) ); $now = new \DateTime(); $diff = $now->diff( $availableFrom )->format( '%a' ); if ( $availableFrom > $now && $diff > 0 ) { $notice = '
' . get_option( 'wc_preorders_cart_product_text', 'Note: this item will be available for shipping in {days_left} days' ) . ''; echo apply_filters( 'preorder_avaiable_date_text_cart', str_replace( '{days_left}', $diff, $notice ), $diff ); } } } public function addPreorderNotices() { global $woocommerce; $actualCart = $woocommerce->cart->get_cart(); $cart = new Cart(); $cart->checkPreOrderProducts( $actualCart ); if ( count( $cart->getPreOrderProducts() ) > 0 ) { wc_add_notice( __( 'Warning! you have selected certain products which are not available right now. You will have to choose a shipping date before you can place your order.', 'pre-orders-for-woocommerce' ), 'notice' ); } } }