2016-07-14 6 views
2

WooCommerce 사이트를 구축 중이며 특정 지불 게이트웨이에 대한 맞춤 처리 수수료를 적용해야합니다.
여기 코드 번호는 How to Add Handling Fee to WooCommerce Checkout입니다.WooCommerce : 대금 상환 지불 방법 (대구)

add_action('woocommerce_cart_calculate_fees','endo_handling_fee'); 
function endo_handling_fee() { 
    global $woocommerce; 

    if (is_admin() && ! defined('DOING_AJAX')) 
     return; 

     $fee = 5.00; 
    $woocommerce->cart->add_fee('Handling', $fee, true, 'standard'); 
} 

이 기능은 모든 거래

가이 기능을 형식에 설정을 몇하고 배달 지불에서만 현금 신청을 할 수 있는가에 요금을 추가

이 내 코드?

다른 대안도 환영합니다. 비슷한 "Payment Gateway Based Fees"플러그인에 대해 알고 있지만 여유가 없습니다.

감사합니다.

+0

가 의견을 보내 주셔서 감사합니다, 나는이 –

+0

따라 업데이트 나쁜 소식은 ... 내 대답을 보라. 죄송합니다. 뭔가 다른 것을 찾아야합니다. – LoicTheAztec

답변

2

이 ... 죄송합니다,

설명 할 수 없습니다 :

  • 문제는 배달 (대구) 지불 방법에 현금 카트 후 다음 단계에서만 사용할 수 있습니다 : Checkout 페이지에 있습니다.

  • 장바구니 페이지에서 결제 방법을 설정하거나 가져올 수 없습니다. 결제 전에는 costumer가 지불 할 결제 수단을 알 수 없기 때문에 설정할 수 없습니다.

이 기능 (코드)은 원하는대로 조정할 수 없습니다.

그 목적으로는 의상 장바구니 페이지에서 결제 방법을 선택하는 것이 필요하다, 어떤 절대적으로 입니다하지 WooCommerce는 연구를 behavio. 다른 사람이이 일을 찾고 들어

0

, 나는 은행 송금에 대한 수수료 (BACS)을 추가하고 싶었, 여기 내가 사용하는 방법입니다 :

//Hook the order creation since it is called during the checkout process: 
add_filter('woocommerce_create_order', 'my_handle_bacs', 10, 2); 

function my_handle_bacs($order_id, $checkout){ 
//Get the payment method from the $_POST 
    $payment_method = isset($_POST['payment_method']) ? wc_clean($_POST['payment_method']) : ''; 

//Make sure it's the right payment method 
    if($payment_method == "bacs"){ 

     //Use the cart API to add recalculate fees and totals, and hook the action to add our fee 
     add_action('woocommerce_cart_calculate_fees', 'my_add_bacs_fee'); 
     WC()->cart->calculate_fees(); 
     WC()->cart->calculate_totals(); 
    } 

    //This filter is for creating your own orders, we don't want to do that so return the $order_id untouched 
    return $order_id; 
} 
function my_add_bacs_fee($cart){ 
    //Add the appropriate fee to the cart 
    $cart->add_fee("Bank Transfer Fee", 40); 
}