Aşağıdaki kodu functions.php dosyasının en sonuna ekleyiniz ve dosyayı güncelle deyiniz.
NOT: Bu işlemleri yaparken temanızın child temasını kullanınız. Aksi taktirde temanıza bir güncelleme geldiğinde bu kod silinecektir ve tekrardan bu ayarları yapmanız gerekmektedir.
// KAPIDA NAKİT ÖDEMEDE EKSTRA ÜCRET EKLEME
add_action( 'woocommerce_cart_calculate_fees', 'custom_handling_fee', 10, 1 );
function custom_handling_fee ( $cart ) {
if ( is_admin() && ! defined( 'DOING_AJAX' ) )
return;
// Seçili ödeme yöntemini al
$chosen_payment_method = WC()->session->get('chosen_payment_method');
// Kapıda ödeme yöntemlerinin kontrolü
if ( in_array( $chosen_payment_method, array('cod', 'wookkkotr') ) ) {
$fee = 75; // Ücret miktarı
$cart->add_fee( 'Kapıda Ödeme Ücreti', $fee, true );
}
}
add_action( 'wp_footer', 'custom_checkout_jqscript' );
function custom_checkout_jqscript() {
if ( is_checkout() && ! is_wc_endpoint_url() ) :
?>
<script type="text/javascript">
jQuery( function($){
// Ödeme yöntemini değiştirdiğinde checkout'u güncelle
$('form.checkout').on('change', 'input[name="payment_method"]', function(){
$(document.body).trigger('update_checkout');
});
});
</script>
<?php
endif;
}