Заказы WooCommerce: время и дата бронирования Echo в подтверждении по электронной почте - PullRequest
1 голос
/ 17 января 2020

Я хочу настроить шаблон customer-completed-order.php в WooCommerce Bookings и добавить следующую строку:

Your session will take place on May 11, 2020, 7:00 pm in timezone: Asia/Tokyo. If this time is incorrect please let us know so we can help you to reschedule.

Я хочу заменить May 11, 2020, 7:00 pm in timezone: Asia/Tokyo с фактическим временем / датой бронирования. Это автоматически отображается в исходном электронном письме, и похоже, что оно опирается на файл booking-summary-list.php, но я не могу просто выбрать время и дату, чтобы отобразить это так, как мне бы хотелось.

Я очень новичок с PHP, поэтому все еще пытаюсь понять, как все это складывается воедино. Я полагаю, что следующие два источника также могут помочь.

https://www.thathandsomebeardedguy.com/retrieve-booking-meta-data

Шаблон электронной почты для бронирования WooCommerce

https://docs.woocommerce.com/document/bookings-snippets

Могу ли я написать что-то вроде следующего, которое я мог бы просто добавить в этот файл customer-completed-order.php? В настоящее время это не работает вообще. Я считаю, что $order, который я передаю, возможно, не нужен или неверен. Также нужно было бы вставить строку фактического времени / даты, но я оставил ее как есть, чтобы увидеть всю функцию и вызов вместе.

<?php 
function get_order_print_date($order) {

    $booking_data = new WC_Booking_Data_Store();
    $booking_ids  = $booking_data->get_booking_ids_from_order_id( $order );
        foreach ( $booking_ids as $booking_id ) {
            $booking = new WC_Booking( $booking_id );
            ///this is where I get stuck and cannot get the information I need
        }
}
?>
<?php get_order_print_date() ?> 

Я пока включу весь файл, который я до сих пор редактировал, чтобы вы могли лучше понять, что я уже взломал вместе. Опять же, супер новичок, поэтому буду очень признателен за любую помощь!

<?php
/**
 * Customer completed order email
 *
 * This template can be overridden by copying it to yourtheme/woocommerce/emails/customer-completed-order.php.
 *
 * HOWEVER, on occasion WooCommerce will need to update template files and you
 * (the theme developer) will need to copy the new files to your theme to
 * maintain compatibility. We try to do this as little as possible, but it does
 * happen. When this occurs the version of the template file will be bumped and
 * the readme will list any important changes.
 *
 * @see https://docs.woocommerce.com/document/template-structure/
 * @package WooCommerce/Templates/Emails
 * @version 3.7.0
 */

if ( ! defined( 'ABSPATH' ) ) {
    exit;
}

/*
 * @hooked WC_Emails::email_header() Output the email header
 */
do_action( 'woocommerce_email_header', $email_heading, $email ); ?>

<?php /* translators: %s: Customer first name */ ?>
<p>
    <?php printf( 
        esc_html__( 'Hi there,', 'woocommerce' ) 
    ); ?>
</p>
<?php 
function get_order_print_date($order) {

    $booking_data = new WC_Booking_Data_Store();
    $booking_ids  = $booking_data->get_booking_ids_from_order_id( $order );
        foreach ( $booking_ids as $booking_id ) {
            $booking = new WC_Booking( $booking_id );
            ///pick out just the booking time and date
        }
}
?>
<?php get_order_print_date() ?> 
<?php /* translators: %s: Site title */ ?>
<p>Your payment has been recieved and your session has been successfully booked!  Thank you.  We are super excited for the chance to share in your adventure.</p>
<h2>Survey</h2>
<p>To make sure we are prepared to be the best teachers possible, please take the time to fill out the survey linked below to give us some necessary background information on your trip.</p>
<p><a class="crashcourse_email_button" href="https://forms.gle/ujhfP3P9vyHFUWhB6">Travel Planning Survey → </a></p>
<h2>Session</h2>
<p>Your session will take place at 8:15am America/Denver time. If this time is incorrect please let us know so we can help you to reschedule.</p>
<?php

/*
 * @hooked WC_Emails::order_details() Shows the order details table.
 * @hooked WC_Structured_Data::generate_order_data() Generates structured data.
 * @hooked WC_Structured_Data::output_structured_data() Outputs structured data.
 * @since 2.5.0
 */
do_action( 'woocommerce_email_order_details', $order, $sent_to_admin, $plain_text, $email );

/*
 * @hooked WC_Emails::order_meta() Shows order meta data.
 */
do_action( 'woocommerce_email_order_meta', $order, $sent_to_admin, $plain_text, $email );

/*
 * @hooked WC_Emails::customer_details() Shows customer details
 * @hooked WC_Emails::email_address() Shows email address
 */
do_action( 'woocommerce_email_customer_details', $order, $sent_to_admin, $plain_text, $email );

/**
 * Show user-defined additonal content - this is set in each email's settings.
 */
if ( $additional_content ) {
    echo wp_kses_post( wpautop( wptexturize( $additional_content ) ) );
}

/*
 * @hooked WC_Emails::email_footer() Output the email footer
 */
do_action( 'woocommerce_email_footer', $email );

Любая помощь будет очень полезна.

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...