我已经将Woocommerce预订与Google同步,这样员工(可以访问共享的Google )就可以在客户预订旅行时立即看到。
我也在努力让产品附加组件出现在描述中。到目前为止,唯一出现的是资源和#的人。以下代码返回一个错误:
致命错误:在第454行的/home/content/12/10265512/html/wp-content/plugins/woocommerce-bookings/includes/integrations/class-wc-bookings-google-calendar-integration.php中调用非对象上的成员函数get_order_item_totals()
我只是为了让这个系统满足我们的需要而在PHP中学习我的方法。如有任何帮助或建议,我们将不胜感激!
public function sync_booking( $booking_id ) {
$event_id = get_post_meta( $booking_id, '_wc_bookings_gcalendar_event_id', true );
$booking = get_wc_booking( $booking_id );
$api_url = $this->calendars_uri . $this->calendar_id . '/events';
$access_token = $this->get_access_token();
$timezone = wc_booking_get_timezone_string();
$product = $booking->get_product();
$summary = '#' . $booking->id . ' - ' . $product->get_title();
$description = '';
// Add resources in description
if ( $resource = $booking->get_resource() ) {
$description .= __( 'Resource #', 'woocommerce-bookings' ) . $resource->ID . ' - ' . $resource->post_title;
}
// Add ProductAdd on in description testing this
if ( $totals = $order->get_order_item_totals() ) {
$i = 0;
foreach ( $totals as $total ) {
$i++;
if ( $i == 1 ) {
$description .= sprintf($total['label']) . PHP_EOL;
$description .= sprintf($total['value']) . PHP_EOL;
}
}
}
// Add persons in description
if ( $booking->has_persons() ) {
$description .= ( '' != $description ) ? PHP_EOL . PHP_EOL : '';
foreach ( $booking->get_persons() as $id => $qty ) {
if ( 0 === $qty ) {
continue;
}
$person_type = ( 0 < $id ) ? get_the_title( $id ) : __( 'Person(s)', 'woocommerce-bookings' );
$description .= sprintf( __( '%s: %d', 'woocommerce-bookings'), $person_type, $qty ) . PHP_EOL;
$description .= wp_kses_post( $product->post->post_excerpt, array() ) . PHP_EOL;
$description .= sprintf("ADDITIONAL NOTES:") . PHP_EOL;
$description .= sprintf("Hey John passing static notes to Calender test") . PHP_EOL;
}
}编辑
我试着添加计费电子邮件和计费电话,但仍然没有得到正确的。我在谷歌日历上看到的只是电子邮件,后面是空白处。
$description .= sprintf( __('Email: %s', 'woocommerce'), $order->billing_email ) . PHP_EOL;
$description .= sprintf( __('Phone: %s', 'woocommerce'), $order->billing_phone ) . PHP_EOL;上面代码中的wp_kses_post方法确实返回了来自WooCommerce的简短描述,并将其放置到Google描述中,所以接下来我将尝试这个方法。
在查看了其他一些网站之后,我仍然在尝试以下几种方法
$description .= sprintf( __('%s', 'woocommerce'), $order->email_order_items_table( true, false, true )) . PHP_EOL;它用于在电子邮件中将相同的信息传递给网站管理员。
<?php echo $order->email_order_items_table( true, false, true ); ?>对于非对象上的成员函数,我仍然得到一个致命的错误调用。几天前,我联系了WooCommerce的支持部门。我会在这里报告以防其他人想和我做同样的事。
发布于 2014-10-11 21:52:26
我能够通过从email_orders_table中提取所有订单信息来解决这个问题。我在张贴我的答案,以防其他人试图做同样的事情。WooCommerce的客户支持无法帮助说明它在他们的支持策略之外,并且考虑了自定义代码。
// Add First Name of Guest
$description .= sprintf( __( 'NAME: %s', 'woocommerce-bookings' ), $booking->get_order()->billing_first_name ) . PHP_EOL;
// Add their email address
$description .= sprintf( __('EMAIL: %s', 'woocommerce-bookings'), $booking->get_order()->billing_email ) . PHP_EOL;
// Add their Phone Number
$description .= sprintf( __('PHONE: %s', 'woocommerce-bookings'), $booking->get_order()->billing_phone ) . PHP_EOL;
// Purchase Notes and WooCommerce Product Add Ons
$description .= sprintf("ADDITIONAL NOTES:") . PHP_EOL;
$description .= sprintf ( __('%s', 'woocommerce-bookings'), strip_tags($order->email_order_items_table( $order->is_download_permitted(), true, true ))) . PHP_EOL ;在去掉HTML标记之后,这一功能非常好,所有的来宾信息都显示在一个私有Google日历中,供全体员工参考。回首过去,我确实是在一个圈子里工作。我都忘了。
do_action( 'woocommerce_email_after_order_table', $order, true, false );https://stackoverflow.com/questions/26280724
复制相似问题