1

I followed the steps in the below link to disable COD for a particular product.

magento 2 payment methods hide by code.

But I need to show a custom message(some of the items in the cart are not eligible for COD) in the payment section, when COD gets disabled. How can achieve this?

1 Answer 1

0

As you didn't post your code, I am not able to help you, but here is the simple method to display a custom message in Magento 2.

<script>
function myFunction() {
   require(['jquery','Magento_Customer/js/customer-data'], function($, customerData){
     $.ajax({
      //your code
     success: function(data)
     {
          var yourmsg = msg+' '+wishlist_link;
          customerData.set('messages', {
               messages: [{
                     type: 'success', //user as per your need
                     text: yourmsg
                        }]
           });
     }
 }
</script>
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.