我已將Woocommerce預訂與Google日曆同步,以便員工(可訪問共享Google日曆)在客戶預訂旅程時即時看到。將Woocommerce預訂信息添加到Google日曆說明中的問題
我試圖獲得產品附加組件以顯示在描述中。到目前爲止唯一顯示的是資源和人數。下面的代碼會返回一個錯誤:
Fatal error: Call to a member function get_order_item_totals() on a non-object in /home/content/12/10265512/html/wp-content/plugins/woocommerce-bookings/includes/integrations/class-wc-bookings-google-calendar-integration.php on line 454
我只是爲了得到這個系統來適應我們的需要而學習我的方法。任何幫助或建議將不勝感激!
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;
}
}
編輯
我嘗試添加結算電子郵件和計費電話,仍然無法得到它的權利。我在Google日曆中看到的所有內容都是電子郵件,接着是空格。
$description .= sprintf(__('Email: %s', 'woocommerce'), $order->billing_email) . PHP_EOL;
$description .= sprintf(__('Phone: %s', 'woocommerce'), $order->billing_phone) . PHP_EOL;
在代碼中wp_kses_post方法了上面並返回從WooCommerce和地方的簡短描述到谷歌日曆的說明,所以我會嘗試下一次。
我仍然在這一點,尋找一些其他網站後撐着走試過以下
$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的支持人員。我會在這裏報告,其他人正在試圖做與我一樣的事情。
我試圖重新使用一些客戶預約,confirmed.php文件中找到的電子郵件文件夾中的代碼,因爲這增加了產品的附加組件給客戶的電子郵件確認。但也想到公共功能addon_price也得到了$ cart_item_data並將其添加到購物車的最終價格。這也會顯示相同的產品添加註釋,並且可以在產品插件插件中找到。 – Jon 2014-10-09 16:05:49