Skip to content

Conversation

@agibson-godaddy
Copy link
Contributor

@agibson-godaddy agibson-godaddy commented May 1, 2025

Summary

This reworks the block payment method registration to get rid of the "translations loaded too early" notice.

Release: #763

Details

Before

Previously we were doing (pseudo-code):

  • For each gateway...
  • Register a woocommerce_blocks_payment_method_type_registration hook
  • In the callback, register a payment method

This was a problem because the get_gateways() call loads the gateway classes, which loads the payment method title, which is translated. For example, this file: https://github.com/gdcorp-partners/woocommerce-gateway-authorize-net-cim/blob/3.10.10/src/class-wc-gateway-authorize-net-cim-credit-card.php#L57-L58 The method_title and other properties are in the constructor.

After

It's reworked like this:

  • Register one single woocommerce_blocks_payment_method_type_registration hook
  • This callback then fires after init
  • In the callback:
    • For each gateway...
    • Register a payment method

It's the exact same end logic, just ensures that we delay that get_gateways() call until after init.

QA

  1. Checkout this branch https://github.com/gdcorp-partners/woocommerce-gateway-authorize-net-cim/pull/113
  2. Ensure your checkout page is using block checkout. Edit it.
  3. Look at the "Payment Options" inside the block.
    • AuthorizeNet appears
  4. Click on it and look at the block settings on the right.

image

image

Before merge

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

@agibson-godaddy agibson-godaddy marked this pull request as ready for review May 1, 2025 12:21
@agibson-godaddy agibson-godaddy merged commit 661ee6a into release/5.15.9 May 1, 2025
5 checks passed
@agibson-godaddy agibson-godaddy deleted the fix/block-payment-methods branch May 1, 2025 12:36
@agibson-godaddy agibson-godaddy mentioned this pull request May 1, 2025
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