Skip to content
Advertisement

Disabling payment methods based on custom shipping methods in WooCommerce

In WooCommerce shop I have 2 delivery method based on Parcel locker. The first is payable in advance, while the second is cash on delivery.

The idea is:

  • easypack_parcel_machines -> only Pay in advance
  • easypack_parcel_machines_cod -> only Cash on delivery

My code below. After applying in both cases, I only have Pay in advance. What’s wrong?

JavaScript

Advertisement

Answer

As both shipping methods start with the same slug, you should simply need to invert them in your if / elseif statement as follows (also there are some other mistake):

JavaScript

or also this way too:

JavaScript

It should work.

User contributions licensed under: CC BY-SA
1 People found this is helpful
Advertisement