Skip to content

"Invalid Payment Method" for COD gateway #27682

@ouija

Description

@ouija

Prerequisites

  • I have have carried out troubleshooting steps and I believe I have found a bug.
  • I have searched for similar bugs in both open and closed issues and cannot find a duplicate.

Describe the bug
Latest version of WooCommerce v4.5.2 and COD Payment Method will throw an "Invalid Payment Method" error if/when billing_postcode field is unset; was not occuring with WooCommerce v4.4.1

Expected behavior
Allow COD Payment method to work without needing billing_postcode field to be set

Actual behavior
Having billing_postcode unset will cause an "Invalid payment method" validation error on checkout when selecting the COD payment method.

Steps to reproduce the bug

  1. Enabled COD payment method in WooCommerce
  2. Add the following code to theme's functions.php file to disable billing_postcode field:
function custom_woocommerce_checkout_fields( $checkout_fields ) {
	unset($checkout_fields['billing'][ 'billing_postcode' ]);
}
add_filter( 'woocommerce_checkout_fields', 'custom_woocommerce_checkout_fields', 2000 );
  1. Try to checkout any product using COD payment method and there will be an "Invalid payment method" validation error.

Isolating the problem

  • I have deactivated other plugins and confirmed this bug occurs when only WooCommerce plugin is active.
  • This bug happens with a default WordPress theme active, or Storefront.
  • I can reproduce this bug consistently using the steps above.

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThe issue is a confirmed bug.CheckoutIssues related to checkout page.needs: author feedbackThe issue/PR needs a response from any of the parties involved in the issue.status: can't reproduceIssues that can't be reproduced.status: staleIssues that have no had any activity for some time.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions