本文介紹了將自定義費用添加到經(jīng)常性的 WooCommerce 訂閱總額的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
function add_woocommerce_stripe_fee() {
if ( ( is_admin() && ! defined( 'DOING_AJAX' ) ) || ! is_checkout() )
return;
$chosen_gateway = WC()->session->chosen_payment_method;
if ( 'stripe' == $chosen_gateway ) {
$fee = (WC()->cart->cart_contents_total * .035) +0.35;
WC()->cart->add_fee( 'Stripe Fee', $fee, false, '' );
}
}
add_action( 'woocommerce_cart_calculate_fees','add_woocommerce_stripe_fee' );
它不會添加重復購物車總數(shù),但適用于普通產(chǎn)品(不適用于訂閱產(chǎn)品).任何幫助將不勝感激.這可能嗎?
It is not adding for recurring cart total but works fine for the normal products ( not working for Subscription products ). Any help would be greatly appreciated. Is this possible.?
推薦答案
我在一個類似問題上提供了更深入的答案.
長話短說嘗試添加這個:
Long story short try adding this:
add_filter( 'woocommerce_subscriptions_is_recurring_fee', '__return_true' );
并查看提供的 Woocommerce doc一些可能對您有所幫助的示例.
And check out the Woocommerce doc that provides some examples that may help you.
這篇關于將自定義費用添加到經(jīng)常性的 WooCommerce 訂閱總額的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網(wǎng)!
【網(wǎng)站聲明】本站部分內(nèi)容來源于互聯(lián)網(wǎng),旨在幫助大家更快的解決問題,如果有圖片或者內(nèi)容侵犯了您的權益,請聯(lián)系我們刪除處理,感謝您的支持!