久久久久久久av_日韩在线中文_看一级毛片视频_日本精品二区_成人深夜福利视频_武道仙尊动漫在线观看

添加自定義“預訂"按鈕到 WooCommerce 產品單頁

Add custom quot;Bookingquot; button to WooCommerce Product single pages(添加自定義“預訂按鈕到 WooCommerce 產品單頁)
本文介紹了添加自定義“預訂"按鈕到 WooCommerce 產品單頁的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

遇到這個問題,感謝您的幫助!

Having trouble with this issue, any help is appreciated!

我希望我的每個 woocommerce 單一產品頁面都有一個立即預訂"按鈕,該按鈕鏈接到我在 WordPress 上創建的名為預訂約會"的頁面.

I want each of my woocommerce single product pages to have a button "Book Now" that links to a page that I created on WordPress titled "Booking Appointments".

那個預訂約會"頁面包含一個我安裝的簡單約會"插件表單(客戶將填寫),我也想讓它自動填充產品的 SKU 或值到表單輸入之一(從上一頁),這樣我就不必每次都輸入它.

That "Booking Appointments" page contains a "Easy Appointment" Plug in Form (that clients will fill out) that I installed which I also want to have it auto populate the product's SKU or values into one of the form inputs (from the pervious page) so that I do not have to enter it each time.

我在網上嘗試了各種方法,但根本不起作用.

I tried a variety of methods online but its not working at all.

推薦答案

更新

這將在單個產品頁面中添加一個立即預訂"按鈕鏈接到您的預訂約會"頁面,通過 URL 傳遞產品 ID、產品 sku...

This will add in single product pages a "Book Now" button linked to your "Booking Appointments" page passing through the URL the product ID, the product sku…

所以代碼將是:

// Add a custom button in Single product pages
add_action( 'woocommerce_single_product_summary', 'replacing_template_single_add_to_cart', 31, 0 );
function replacing_template_single_add_to_cart() {
    global $product;

    $product_id = $product->get_id();
    $sku = $product->get_sku();

    // Set below the page ID, your button text and link parameters to pass in url
    $page_id = 124;
    $button_text = __('Book Now', 'woocommerce');
    $link = get_permalink( $page_id ) . '?id=' . $product_id . '&sku=' . $sku;

    // Output your custom text
    echo '<a href="'.$link.'" class="book-now button">'.$button_text.'</a>';

}

代碼位于活動子主題(或主題)的 function.php 文件或任何插件文件中.

在您的預訂約會"頁面表單中,您將能夠從帶有 $_GET 的 URL 中獲取值以填充必要的字段 帶有您將在其中使用的附加腳本:

In your your "Booking Appointments" page form you will be able to get the values from the URL with $_GET to populate necessary fields with an additional scripts in which you will use:

$product_id = $_GET['id'];
$sku = $_GET['sku'];

在 WooCommerce 3+ 中測試和工作.

Tested and works in WooCommerce 3+.

這篇關于添加自定義“預訂"按鈕到 WooCommerce 產品單頁的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!

【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!

相關文檔推薦

Add programmatically a downloadable file to Woocommerce products(以編程方式將可下載文件添加到 Woocommerce 產品)
Get today#39;s total orders count for each product in Woocommerce(獲取今天 Woocommerce 中每種產品的總訂單數)
Add Custom registration fields in WooCommerce and phone field validation issue(在 WooCommerce 和電話字段驗證問題中添加自定義注冊字段)
Add a select field that will change price in Woocommerce simple products(在 Woocommerce 簡單產品中添加一個將更改價格的選擇字段)
Add custom columns to admin products list in WooCommerce 3(在 WooCommerce 3 中將自定義列添加到管理產品列表)
Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
主站蜘蛛池模板: 欧美a√ | 亚州综合一区 | 国产在线观看不卡一区二区三区 | 欧美综合国产精品久久丁香 | 亚洲国产精品视频 | 人人草人人干 | www.男人天堂.com | 精品一区二区av | 色婷婷综合久久久中字幕精品久久 | 国产免费一二三区 | 视频三区 | 亚洲成人av在线播放 | www.日日干| 人人玩人人添人人澡欧美 | 日韩美女在线看免费观看 | 亚洲一区视频 | 久久中文字幕一区 | 国产日韩免费视频 | 日韩精品 | 精品欧美一区二区精品久久久 | 黄网在线观看 | 精品视频久久久久久 | 亚洲美女网站 | 国产一区三区在线 | 亚洲天堂精品一区 | 久久一二区| 亚洲精品一区二区三区中文字幕 | 日韩三级电影一区二区 | 亚洲精品中文字幕av | 中文字幕亚洲精品 | 日韩电影免费在线观看中文字幕 | 成人高清网站 | 韩日在线 | 免费久久久久久 | 国产高清在线精品一区二区三区 | 日本韩国电影免费观看 | 久久久久久免费看 | 精国产品一区二区三区 | 色综合一区二区 | 中文字幕一区二区三区日韩精品 | 欧美精品区 |