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

Woocommerce 結帳頁面上的額外貝寶費用

Additional paypal fee on Woocommerce checkout page(Woocommerce 結帳頁面上的額外貝寶費用)
本文介紹了Woocommerce 結帳頁面上的額外貝寶費用的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!

問題描述

限時送ChatGPT賬號..

在 Woocommerce 中,我們試圖在通過 Paypal 支付網關購買的訂單中增加額外費用.

In Woocommerce, we are trying to add an additional cost to the order when is purchased via Paypal payment gateway.

我們通過這種方式改變了發送到 Paypal 的價格:

We did it changing the price that is sent to Paypal this way:

add_filter('woocommerce_paypal_args', 'addition_pay');

function addition_pay($paypal_args){
        $new_value=$paypal_args['amount_1']+10;
        $paypal_args['amount_1']=$new_value;
        return $paypal_args;
} 

它有效,但問題是在付款過程之后,這筆額外費用不會反映在訂單和電子郵件通知中.

It works, but the problem is after the payment process, this additional cost is not reflected in Orders and email notifications.

這可以通過某種方式解決嗎?任何幫助表示贊賞.

Is this can be solved in some way? Any help is appreciated.

推薦答案

您最好根據支付網關(此處為您的 Paypal)添加費用,如下所示:

You should better add a fee based on payment gateway (here Paypal for you), like in the following:

// Add a fee of 10.00 when Paypal is chosen
add_action( 'woocommerce_cart_calculate_fees', 'custom_paypal_additional_fee', 20, 1 );
function custom_paypal_additional_fee( $cart ) {
    if ( is_admin() && ! defined( 'DOING_AJAX' ) )
        return;

    if( WC()->session->get( 'chosen_payment_method' ) == 'paypal' )
        $cart->add_fee( __( 'Paypal fee', 'woocommerce' ), 10.00 );
}

// Add the information on checkout paypal text gateways section
add_filter('woocommerce_gateway_icon', 'custom_paypal_gateway_text', 20, 2 );
function custom_paypal_gateway_text( $html, $gateway_id ) {
    if( $gateway_id == 'paypal' )
        $html .= ' <small class="paypal-fee">(+ '.wc_price(10.00).')</small>';

    return $html;
}

// Enable ajax update checkout event when choosing a gateway to refresh the fee
add_action('wp_footer', 'payment_gateways_update_checkout_event' );
function payment_gateways_update_checkout_event() {
    ?>
    <script type="text/javascript">
        (function($){
            $('form.checkout').on( 'change', 'input[name^="payment_method"]', function() {
                var t = { updateTimer: !1,  dirtyInput: !1,
                    reset_update_checkout_timer: function() {
                        clearTimeout(t.updateTimer)
                    },  trigger_update_checkout: function() {
                        t.reset_update_checkout_timer(), t.dirtyInput = !1,
                        $(document.body).trigger("update_checkout")
                    }
                };
                $(document.body).trigger('update_checkout')
            });
        })(jQuery);
    </script>
    <?php
}

代碼位于活動子主題(或活動主題)的 function.php 文件中.經過測試和工作.

這篇關于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)
主站蜘蛛池模板: 男人阁久久 | 一区二区视频在线观看 | 黄色一级免费看 | 欧美一级片在线 | 在线精品国产 | 午夜激情在线视频 | 国产一区二区欧美 | 亚洲视频在线观看一区二区三区 | av无遮挡| 国产精品久久久久一区二区三区 | av在线免费观看不卡 | 精品婷婷 | 久久狠狠 | 国产视频不卡一区 | 日本久久综合 | 在线观看免费高清av | 99久久婷婷国产综合精品电影 | 国产日韩欧美中文字幕 | 久久久精品国产 | 亚洲精品在线播放 | 一区二区免费视频 | 中文字幕精品视频在线观看 | 国产精品影视 | 久久国内精品 | 国产精品久久久久久中文字 | 日一区二区 | 欧美一二三区 | 精品国产精品一区二区夜夜嗨 | 日日操日日舔 | 欧美老妇交乱视频 | 黄视频网址 | 国产精品久久久精品 | 精品久久久久久久 | 成人精品一区亚洲午夜久久久 | 亚洲综合在线视频 | 欧美国产精品一区二区三区 | 福利成人 | 久久一| 亚洲乱码一区二区 | 日韩三级在线 | 亚洲精品一区中文字幕乱码 |