久久久久久久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 我的帳戶和管理員用戶頁面)
主站蜘蛛池模板: 国产精品揄拍一区二区 | 欧美一级网站 | 久久精品一区二区三区四区 | 狠狠操网站| 久久噜噜噜精品国产亚洲综合 | 天天天天天天天干 | 久久综合一区 | 日韩精品一区二区三区免费观看 | 韩国av一区二区 | 欧美一区二区久久 | 国产乱码精品一区二区三区忘忧草 | 99爱国产 | 亚洲精品一区二区在线观看 | 久久久国产精品入口麻豆 | 国产美女精品视频 | 日韩美女一区二区三区在线观看 | 国产亚洲精品久久yy50 | 超碰免费在线观看 | 三区在线观看 | 久久亚洲天堂 | 亚洲区一区二 | 麻豆久久精品 | 色综合视频在线 | 免费国产一区 | 日本高清视频在线播放 | 国产精品一区二区久久 | 午夜视频在线播放 | 日本黄视频在线观看 | 国产精品日日摸夜夜添夜夜av | 美女天堂在线 | 日韩欧美网 | 超碰91在线| 欧美一区二区免费 | 国产精品久久二区 | 午夜精品一区二区三区在线观看 | 午夜男人天堂 | 亚洲视频一区在线观看 | 国产农村一级片 | 国产a区 | 亚洲精品一区二区久 | 精品日韩在线观看 |