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

自定義結帳“下訂單"按鈕輸出html

Customizing checkout quot;Place Orderquot; button output html(自定義結帳“下訂單按鈕輸出html)
本文介紹了自定義結帳“下訂單"按鈕輸出html的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

我需要添加 Facebook Pixel 代碼來跟蹤事件,每次客戶點擊 WooCommerce 結賬頁面上的下訂單"時.

我已嘗試在 Checkout 模板中找到按鈕行,并以這種方式對其進行

但是我找不到按鈕的代碼.

如何添加代碼?
或者我在哪里可以找到編輯它的行?這是哪個模板?

謝謝

解決方案

如果您想對結帳提交按鈕進行一些更改,您有兩種方法:

1) 使用掛在 woocommerce_order_button_html 過濾器鉤子中的自定義函數,這樣:

add_filter('woocommerce_order_button_html', 'custom_order_button_html');函數 custom_order_button_html( $button ) {//按鈕的文本$order_button_text = __('下訂單', 'woocommerce');//這里是你的 Javascript 事件$js_event = "fbq('track', 'AddPaymentInfo');";//在這里進行更改(替換按鈕的代碼):$button = '<input type="submit" onClick="'.$js_event.'" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '"/>';返回 $ 按鈕;}

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

<小時>

2) 覆蓋模板 checkout/payment.php,您將定位此代碼(第 50 行):

<?php echo apply_filters( 'woocommerce_order_button_html', '<input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' .esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '"/>' );?>

改為:

' );?>

相關文檔:

  • I need to add the Facebook Pixel code to track an event, every time a client clicks the "Place Order" on the WooCommerce checkout page.

    I've tried to find the button line at the Checkout template, and edit it this way:

    <button onClick="fbq('track', 'AddPaymentInfo');">Place Order</button>
    

    But I can't locate the code for the button.

    How could I add the code?
    Or where can I find the line to edit it? Which template is it?

    Thanks

    解決方案

    If you want to make some changes on the checkout submit button, you will have 2 ways:

    1) Using a custom function hooked in woocommerce_order_button_html filter hook, this way:

    add_filter( 'woocommerce_order_button_html', 'custom_order_button_html');
    function custom_order_button_html( $button ) {
    
        // The text of the button
        $order_button_text = __('Place order', 'woocommerce');
    
        // HERE your Javascript Event
        $js_event = "fbq('track', 'AddPaymentInfo');";
    
        // HERE you make changes (Replacing the code of the button):
        $button = '<input type="submit" onClick="'.$js_event.'" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '" />';
    
        return $button;
    }
    

    Code goes in function.php file of your active child theme (or theme) or also in any plugin file.


    2) Overriding the template checkout/payment.php and you will target this code (on line 50):

    <?php echo apply_filters( 'woocommerce_order_button_html', '<input type="submit" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '" />' ); ?>
    

    Changed to this:

    <?php 
        // Set HERE your javascript event
        $js_event = $js_event = "fbq('track', 'AddPaymentInfo');";
    
        echo apply_filters( 'woocommerce_order_button_html', '<input type="submit" onClick="'.$js_event.'" class="button alt" name="woocommerce_checkout_place_order" id="place_order" value="' . esc_attr( $order_button_text ) . '" data-value="' . esc_attr( $order_button_text ) . '" />' ); ?>
    

    Related documentation:

    • Template Structure + Overriding Templates via a Theme
    • Woocommerce templates file checkout/payment.php

    All code is tested and works. here is the output for both solutions:

    這篇關于自定義結帳“下訂單"按鈕輸出html的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持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 中將自定義列添加到管理產品列表)
Add birthday field to WooCommerce my account and admin user page(將生日字段添加到 WooCommerce 我的帳戶和管理員用戶頁面)
主站蜘蛛池模板: 在线播放国产一区二区三区 | h视频在线看 | 7777在线视频免费播放 | 真人女人一级毛片免费播放 | 91看片网站 | 一区二区三区在线 | 亚洲欧美中文日韩在线v日本 | 国产真实乱全部视频 | 伊人狠狠干 | 可以免费观看的av片 | 99视频精品 | 99精品99久久久久久宅男 | 黄色一级片视频 | 天天天操 | 中文字幕欧美在线观看 | 伊人爽 | 亚洲国产成人av好男人在线观看 | 人人干人人干人人 | 国产精品久久精品 | 蜜臀网 | 久草视频在线播放 | 亚洲一区亚洲二区 | 九九精品在线 | 成年人视频在线免费观看 | 国产精品久久久久久久久久 | 免费在线看a | 99re热精品视频 | 亚洲成年在线 | 亚州无限乱码 | 国产伦精品一区二区三区在线 | 国产精品69毛片高清亚洲 | 精品国产91 | 亚洲一区二区中文字幕 | 亚洲成人精品一区 | 亚洲综合区 | 久久久久久免费毛片精品 | 国产一区二区三区在线观看免费 | 国产亚洲欧美另类一区二区三区 | 亚洲性视频网站 | 中文字幕国产精品视频 | 美日韩中文字幕 |