Dear Customer Support,
I hope this message finds you well. I am reaching out to seek assistance regarding the implementation of a Cash on Delivery (COD) fee in my WooCommerce store. Despite trying various solutions, including plugins and code snippets, I have been unable to achieve the desired outcome.
My objective is to display the fee associated with Cash on Delivery during the checkout process. I have consulted multiple online resources and followed instructions provided by various plugins, but unfortunately, none have yielded the desired result.
I would appreciate it if you could provide detailed guidance on how to properly configure this feature in my store. Any information, advice, or step-by-step instructions would be highly valued.
Here are some additional details:
- WooCommerce version in use: 8.5.1
- Payment-related plugins installed: WooCommerce PayPal Payments 2.4.3 and WooCommerce Stripe Gateway 7.9.1
- Snippets or customizations attempted:` add_action( ‘woocommerce_cart_calculate_fees’, ‘bbloomer_add_checkout_fee_for_gateway’ );
function bbloomer_add_checkout_fee_for_gateway() {
$chosen_gateway = WC()->session->get( ‘chosen_payment_method’ );
if ( $chosen_gateway == ‘cod’ ) {
WC()->cart->add_fee( ‘Extra Fee’, 5 );
}
}
add_action( ‘woocommerce_after_checkout_form’, ‘bbloomer_refresh_checkout_on_payment_methods_change’ );
function bbloomer_refresh_checkout_on_payment_methods_change(){
wc_enqueue_js( ”
$( ‘form.checkout’ ).on( ‘change’, ‘input[name^=\’payment_method\’]’, function() {
$(‘body’).trigger(‘update_checkout’);
});
“);
}`
I am available to provide any further information that may facilitate the resolution of this issue. Thank you in advance for your support, and I look forward to your response.
Best regards,