2

I am currently testing and trying to checkout on this site after adding to cart. I have 4 main payment methods:

  • Paypal
  • Cash on Delivery
  • Click & Collect
  • Credit Card Payment

For orders less than 50.00 Euro, a delivery charge of 5.00 Euro applies. This is shown accordingly by the Paypal, Cash on Delivery and CC Payment. However for Click & Collect, the delivery charge is still showing instead of the Shop pickup option and therefore the calculation of the total still includes the 5.00 Euro delivery charge - which is not required.

From Woocommerce backend, the Click & Collect is shown to have 0.00 Euro as a price as per https://imgur.com/MOuxFA . However, this is not being reflected on the site when checking out. Also the 5.00 Euro delivery charge applies to the correct options too.

I have tried ajax calling in javascript to change the delivery charge from the front-end and push the data to PHP. However, this does not work and the orders saved in the backend are with the incorrect total price. Also, I have also tried to tried to 'trick' Woocommerce by obtaining the sub-total price instead for the click and collect however I cannot apply this to re-iterate for every radio button selection on checkout. Code below:

function wc_modify_cart_price(){

    return WC()->cart->get_cart_subtotal();

}

add_filter( 'woocommerce_cart_total', 'wc_modify_cart_price' ); 

This also does not work from my end.

I also noticed that the checked value for the radio inputs was not being set correctly and therefore wrote this below to make sure this marks accordingly, however, this does not show on the link above since it is on my testing environment.

$('.input-radio').click(function(){
    $(this).attr('checked','checked');
    $('.input-radio').not(this).removeAttr('checked');

    var attr = $('#payment_method_cheque').attr('checked');

    if(typeof attr !== typeof undefined && attr !== false){
        $('.woocommerce-shipping-totals').css('display','none');
    }else{
        $('.woocommerce-shipping-totals').css('display','block');
    }

});

Any help on these steps is appreciated. Thanks.

sacit
  • 21
  • 1
  • This might help you: https://stackoverflow.com/questions/45739331/change-checkout-submit-button-text-for-a-specific-payment-method-in-woocommerce and you can use http://hookr.io/filters/woocommerce_package_rates/ hook/filter to change delivery costs. – MrEbabi Nov 30 '19 at 05:52

0 Answers0