Skip to content

Fix "event is not a function" error on My Payment Methods page - #867

Merged
agibson-godaddy merged 3 commits into
release/6.2.5from
mwc-20379
Oct 27, 2026
Merged

agibson-godaddy merged 3 commits into
release/6.2.5from
mwc-20379

Conversation

@smoen-godaddy

@smoen-godaddy smoen-godaddy commented Oct 26, 2026 •

Copy link
Copy Markdown

Summary

Fixes an uncaught TypeError: event is not a function thrown by the My Payment Methods handler whenever a customer has at least one saved payment method.

Story: MWC-20379

Release: TBD

Details

In sv-wc-payment-gateway-my-payment-methods.coffee, the click handler for the "Add payment method" button was written as .on 'click', event ->. Without parentheses, CoffeeScript compiles this to .on('click', event(function() {...})), a call to window.event, which isn't a function. The constructor throws at that line, so the handler never finishes setting up and the guard that stops a disabled "Add payment method" button from navigating is never registered.

The fix adds the missing parentheses: .on 'click', ( event ) ->. The thin arrow is kept because the body relies on $( this ) being the clicked button. The dist asset and source map are rebuilt.

The error only appears when a saved method exists, because WooCommerce only renders the payment methods table then. Other framework-based gateways bundling an affected version are likely affected too.

UI Changes

None.

QA

Setup

  • A framework-based gateway with saved payment methods enabled (for example Authorize.Net CIM in sandbox mode)

Steps

  1. Add a payment method, then open My Account > Payment Methods with the browser console open
    • No event is not a function error is logged
  2. Click Edit on a saved method, then click the "Add payment method" button
    • The button does not navigate while editing
  • Code review

Before merge

  • I have confirmed these changes in each supported minor WooCommerce version

@smoen-godaddy smoen-godaddy self-assigned this Oct 26, 2026
@smoen-godaddy

Copy link
Copy Markdown
Author

Hi @agibson-godaddy , I’ve opened a framework fix for MWC-20379: #867. A missing pair of parentheses in the My Payment Methods CoffeeScript (.on 'click', event ->) throws “event is not a function” for any customer with a saved payment method. It affects every plugin bundling framework 6.2.4, and I confirmed it on Authorize.Net. It’s a one-liner plus the rebuilt dist. Two questions: should this go out as 6.2.5 with #864 or on its own, and who triggers the framework release? I’ve cut release/3.10.22 for Authorize.Net (#152) and will pin the new framework version in the story PR once it’s tagged.

@smoen-godaddy

Copy link
Copy Markdown
Author

Tested this branch (7fae387) in WooCommerce Authorize.Net Gateway 3.10.22-dev.1, installed via a zip built from the branch’s own dist. On My Account > Payment Methods with a saved method, there is no event is not a function error in the console. The disabled “Add payment method” button no longer navigates while a method is being edited. Nickname save/cancel, set default, and delete (Cancel and OK) all work as before. Local PHPUnit errors identically (18 of 26) with and without this change on PHP 8.5

@agibson-godaddy agibson-godaddy mentioned this pull request Oct 27, 2026
2 tasks
@agibson-godaddy
agibson-godaddy changed the base branch from master to release/6.2.5 October 27, 2026 10:34
@agibson-godaddy
agibson-godaddy merged commit 7580c0e into release/6.2.5 Oct 27, 2026
5 checks passed
@agibson-godaddy
agibson-godaddy deleted the mwc-20379 branch October 27, 2026 10:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants