所以,我的网站涉及预订系统,流程如下:
我已成功创建订单。理想情况下,我希望能够将客人发送到他们的“购物车”页面,并附上他们的预订订单(仅在主持人批准预订后)。这样,除了主机的初始ACCEPT或DECLINE之外,WooCommerce可以处理所有内容。
问题:
代码:
在首页预订页面:
$y_booking_order = wc_create_order();
$y_booking_order->add_product( get_product( $san_y_id ), $san_num_days);
$y_booking_order->calculate_totals();
$y_booking_order->update_status('on-hold');
update_post_meta($y_booking_order->id, '_arrival_date', $san_date_arr);
update_post_meta($y_booking_order->id, '_departure_date', $san_date_dep);
update_post_meta($y_booking_order->id, '_request_sender', $san_user_id);
update_post_meta($y_booking_order->id, '_customer_user', get_current_user_id());
// do I add to cart here? If so, how to stop guest from paying until after host approves?
到目前为止,一旦创建订单,我只是让主机将订单状态从“暂停”更改为“待定”。现在我只想让客人付钱......
思考?
答案 0 :(得分:0)
如果您没有收集某种类型的预授权,则“待处理”是状态所在的位置。
就发送发票而言,挖掘WooCommerce的代码并重新组织它以减少脂肪产生以下功能,这应该允许您以编程方式发送发票电子邮件,就像您一样告诉它在编辑订单时从菜单中发送发票:
function send_invoice_email($post_id) {
$order = wc_get_order($post_id);
wc_switch_to_site_locale();
do_action('woocommerce_before_resend_order_emails', $order);
// Ensure gateways are loaded in case they need to insert data into the emails.
WC()->payment_gateways();
WC()->shipping();
// Load mailer.
$mailer = WC()->mailer();
$email_to_send = 'customer_invoice';
$mails = $mailer->get_emails();
if (!empty($mails)) {
foreach ($mails as $mail) {
if ($mail->id == $email_to_send) {
$mail->trigger($order->get_id(), $order);
$order->add_order_note( sprintf( __('%s email notification manually sent.', 'woocommerce'), $mail->title), false, true);
}
}
}
do_action('woocommerce_after_resend_order_email', $order, $email_to_send);
wc_restore_locale();
}