【发布时间】:2020-01-17 10:22:23
【问题描述】:
我想在 WooCommerce Bookings 中自定义 customer-completed-order.php 模板,并想添加如下一行。
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 Booking email template
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 );
任何帮助都会非常有帮助。
【问题讨论】:
标签: php wordpress woocommerce woocommerce-bookings