久久久久久久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)
主站蜘蛛池模板: 91精品国产91久久久久久密臀 | 亚洲一区中文字幕 | 亚洲精品一区二区三区中文字幕 | 久久综合伊人一区二区三 | 日韩国产精品一区二区三区 | 三级欧美| 日韩欧美在线观看视频网站 | 欧美一区二区三区国产精品 | 欧美国产日韩成人 | 免费视频二区 | 日韩精品一区二区三区在线播放 | 夜夜爽99久久国产综合精品女不卡 | 97av| 夜夜艹 | 亚洲一区二区免费电影 | 热久久免费视频 | 中文字幕乱码视频32 | 国产激情第一页 | 欧美日韩一区在线 | 亚洲一区二区三区四区在线观看 | 久久久看 | 久久极品| 国产精品久久免费观看 | 欧美一区二区三区视频 | 欧美日韩精品一区二区三区蜜桃 | 日韩在线精品强乱中文字幕 | 国产精品久久久久久久免费大片 | 黄色免费av | 91社区在线观看高清 | 美女爽到呻吟久久久久 | 玖玖视频免费 | 日韩福利| 亚洲欧美视频一区 | 国产日韩欧美中文 | 亚洲成人在线视频播放 | 九九热九九 | 国产成人精品一区二区三区四区 | 成人午夜精品一区二区三区 | 亚洲一二三区精品 | 成人在线播放 | 超碰网址 |