pbootcms网站模板|日韩1区2区|织梦模板||网站源码|日韩1区2区|jquery建站特效-html5模板网

自定義結帳“下訂單"按鈕輸出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 我的帳戶和管理員用戶頁面)
主站蜘蛛池模板: 移动机器人产业联盟官网 | 重庆监控_电子围栏设备安装公司_门禁停车场管理系统-劲浪科技公司 | 钢板仓,大型钢板仓,钢板库,大型钢板库,粉煤灰钢板仓,螺旋钢板仓,螺旋卷板仓,骨料钢板仓 | 广州中央空调回收,二手中央空调回收,旧空调回收,制冷设备回收,冷气机组回收公司-广州益夫制冷设备回收公司 | 培训中心-翰香原香酥板栗饼加盟店总部-正宗板栗酥饼技术 | 理化生实验室设备,吊装实验室设备,顶装实验室设备,实验室成套设备厂家,校园功能室设备,智慧书法教室方案 - 东莞市惠森教学设备有限公司 | 合肥触摸一体机_触摸查询机厂家_合肥拼接屏-安徽迅博智能科技 | 密集架|电动密集架|移动密集架|黑龙江档案密集架-大量现货厂家销售 | 水压力传感器_数字压力传感器|佛山一众传感仪器有限公司|首页 | 高温链条油|高温润滑脂|轴承润滑脂|机器人保养用油|干膜润滑剂-东莞卓越化学 | 聚氨酯复合板保温板厂家_廊坊华宇创新科技有限公司 | 电销卡 防封电销卡 不封号电销卡 电话销售卡 白名单电销卡 电销系统 外呼系统 | 工业废水处理|污水处理厂|废水治理设备工程技术公司-苏州瑞美迪 今日娱乐圈——影视剧集_八卦娱乐_明星八卦_最新娱乐八卦新闻 | 手机存放柜,超市储物柜,电子储物柜,自动寄存柜,行李寄存柜,自动存包柜,条码存包柜-上海天琪实业有限公司 | 广东护栏厂家-广州护栏网厂家-广东省安麦斯交通设施有限公司 | AR开发公司_AR增强现实_AR工业_AR巡检|上海集英科技 | 篮球架_乒乓球台_足球门_校园_竞技体育器材_厂家_价格-沧州浩然体育器材有限公司 | 微信聊天记录恢复_手机短信删除怎么恢复_通讯录恢复软件下载-快易数据恢复 | 手持气象站_便携式气象站_农业气象站_负氧离子监测站-山东万象环境 | 美的商用净水器_美的直饮机_一级代理经销商_Midea租赁价格-厂家反渗透滤芯-直饮水批发品牌售后 | 超细粉碎机|超微气流磨|气流分级机|粉体改性设备|超微粉碎设备-山东埃尔派粉碎机厂家 | 深圳美安可自动化设备有限公司,喷码机,定制喷码机,二维码喷码机,深圳喷码机,纸箱喷码机,东莞喷码机 UV喷码机,日期喷码机,鸡蛋喷码机,管芯喷码机,管内壁喷码机,喷码机厂家 | 贵州成人高考网_贵州成考网 | 报警器_家用防盗报警器_烟雾报警器_燃气报警器_防盗报警系统厂家-深圳市刻锐智能科技有限公司 | 新疆乌鲁木齐网站建设-乌鲁木齐网站制作设计-新疆远璨网络 | 塑料瓶罐_食品塑料瓶_保健品塑料瓶_调味品塑料瓶–东莞市富慷塑料制品有限公司 | 直流电能表-充电桩电能表-导轨式电能表-智能电能表-浙江科为电气有限公司 | 经济师考试_2025中级经济师报名时间_报名入口_考试时间_华课网校经济师培训网站 | 淘气堡_室内儿童乐园_户外无动力儿童游乐设备-高乐迪(北京) | 「安徽双凯」自动售货机-无人售货机-成人用品-自动饮料食品零食售货机 | 右手官网|右手工业设计|外观设计公司|工业设计公司|产品创新设计|医疗产品结构设计|EMC产品结构设计 | 广州番禺搬家公司_天河黄埔搬家公司_企业工厂搬迁_日式搬家_广州搬家公司_厚道搬迁搬家公司 | 脉冲除尘器,除尘器厂家-淄博机械 | ★店家乐|服装销售管理软件|服装店收银系统|内衣店鞋店进销存软件|连锁店管理软件|收银软件手机版|会员管理系统-手机版,云版,App | 穿线管|波纹穿线管|包塑金属软管|蛇皮管?闵彬专注弱电工程? | 原色会计-合肥注册公司_合肥代理记账公司_营业执照代办 | 开业庆典_舞龙舞狮_乔迁奠基仪式_开工仪式-神挚龙狮鼓乐文化传媒 | 农业仪器网 - 中国自动化农业仪器信息交流平台 | 厂厂乐-汇聚海量采购信息的B2B微营销平台-厂厂乐官网 | 苏州注册公司_苏州代理记账_苏州工商注册_苏州代办公司-恒佳财税 | 杭州公司变更法人-代理记账收费价格-公司注销代办_杭州福道财务管理咨询有限公司 |