' . nl2br( esc_html( $note ) ) . '
'; } catch ( \Throwable $e ) { OrderingPolicy::report_display( $e ); } } /** * The note for an email, plain text, or '' for none: only a customer * email in `NOTE_EMAILS`, only with the setting on, only for an order with * a valid scheduled time (never a time it wasn't scheduled for). * * @param mixed $order Order. * @param mixed $sent_to_admin Whether the email goes to the store. * @param mixed $email The `WC_Email`. * @return string */ private static function note( $order, $sent_to_admin, $email ) { if ( $sent_to_admin || ! $email instanceof \WC_Email || ! in_array( $email->id, self::NOTE_EMAILS, true ) || ! Behaviour::scheduled_order_note() ) { return ''; } $ts = OrderMeta::get_scheduled_for( $order ); if ( null === $ts ) { return ''; } // Only `{scheduled_for}`: the closed message's tokens map to themselves, so they stay as typed. $note = OrderingPolicy::fill( Behaviour::scheduled_order_note_text(), array( 'next_open' => '{next_open}', 'closures_label' => '{closures_label}', 'scheduled_for' => OrderingPolicy::format_time( $ts ), ) ); /** * The scheduled-order note in a customer email (OW-062), plain text, * `{scheduled_for}` already replaced. Return '' to show none. It is * escaped when printed, so markup shows as text. * * @param string $note The note. * @param WC_Order $order Order. * @param WC_Email $email Email. */ $note = apply_filters( 'hourgate_scheduled_order_note', $note, $order, $email ); return is_string( $note ) ? trim( $note ) : ''; } /** * Add the "Scheduled for" row after the payment method (or last when there is none). * * @param mixed $total_rows Rows WooCommerce built, keyed (`cart_subtotal`, `payment_method`, ...). * @param mixed $order Order. * @return mixed */ public static function add_totals_row( $total_rows, $order ) { if ( ! is_array( $total_rows ) ) { return $total_rows; } try { $rows = self::rows( $order ); if ( ! $rows ) { return $total_rows; } if ( ! array_key_exists( 'payment_method', $total_rows ) ) { return array_merge( $total_rows, $rows ); } $result = array(); foreach ( $total_rows as $key => $row ) { $result[ $key ] = $row; if ( 'payment_method' === $key ) { $result = array_merge( $result, $rows ); } } return $result; } catch ( \Throwable $e ) { OrderingPolicy::report_display( $e ); return $total_rows; } } /** * The admin order screen: the scheduled time and the "placed while closed" flag. * * @param mixed $order Order. * @return void */ public static function admin_box( $order ) { try { $rows = self::rows( $order ); if ( OrderMeta::is_placed_while_closed( $order ) ) { $rows['placed_while_closed'] = array( 'label' => __( 'Placed while the store was closed', 'hourgate' ), 'value' => __( 'Yes', 'hourgate' ), ); } if ( ! $rows ) { return; } echo '' . esc_html( (string) $row['label'] ) . ' ' . esc_html( (string) $row['value'] ) . '
'; } echo '