Skip to content

Add support for Bacs to handle Pre-Orders #4024

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Mar 7, 2025

Conversation

asumaran
Copy link
Contributor

@asumaran asumaran commented Mar 6, 2025

Part of #3803

Changes proposed in this Pull Request:

  • Added support for pre-orders by initializing the maybe_init_pre_orders method in the constructor.

  • Introduced the hide_bacs_for_pre_orders_charge_upon_release method to remove the Bacs payment option for pre-orders that are charged upon release. This prevents customers from selecting Bacs for pre-orders that are not charged upfront, as Bacs does not support delayed charges. The limitation is similar to the one affecting subscriptions with free trials.

Testing instructions

Important

First, make sure that the business in your Stripe account is located in the UK (link) and that your default currency is GBP (link). Otherwise you won't be able to see Bacs as a payment option.

Important

Update the store country to the UK and set the currency to GBP in the WooCommerce settings.

Important

Also, make sure the Bacs feature is enabled. You can use the following to do that:
wp option update _wcstripe_feature_lpm_bacs 'yes'. Also, you can enable Bacs using the dev tools extension.

  • Switch to this branch.
  • Install the WooCommerce Pre-Order extension

Test Pre-Orders that charge upon release

  • Create a simple product.
  • Enable pre-orders for the product.
  • Define a future availability date.
  • Set "When to Charge" to "Upfront"
  • Add the product to cart.
  • Checkout with Bacs without issues.

Test Pre-Orders that charge upon release

  • Create a simple product.
  • Enable pre-orders for the product.
  • Define a future availability date.
  • Set "When to Charge" to "Upon release"
  • Add the product to cart and Bacs should not be available as payment option on the checkout form.

Changelog entry

  • This Pull Request does not require a changelog entry. (Comment required below)
Changelog Entry Comment

Comment

Post merge

@asumaran asumaran changed the title Hide Bacs payment option for pre-orders that are charged upon Hide Bacs payment option for pre-orders that are charged upon release Mar 6, 2025
@asumaran asumaran self-assigned this Mar 6, 2025
@asumaran asumaran changed the title Hide Bacs payment option for pre-orders that are charged upon release Add support for Bacs to handle Pre-Orders Mar 6, 2025
@asumaran asumaran marked this pull request as ready for review March 6, 2025 19:37
@asumaran asumaran requested review from a team and lovo-h and removed request for a team March 6, 2025 19:38
Comment on lines 126 to 133
/**
* Hides the Bacs payment method for subscriptions with free trials.
*
* This function removes the "stripe_bacs_debit" payment gateway from the available payment methods
* if the cart contains a subscription with a free trial and the total cart amount is zero.
*
* @return void
*/
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have been included in #3987.

Copy link
Contributor

@lovo-h lovo-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Summary

The code changes look good and test as expected ✅

I left a few nit comments, but they were not blockers.

Test Instructions

  • 🟢 Test Pre-Orders that charge Upfront.
    • Checkout with Bacs without issues.
  • 🟢 Test Pre-Orders that charge Upon release.
    • Bacs is not available as a payment option in the checkout form.

@asumaran asumaran requested a review from lovo-h March 6, 2025 23:21
Copy link
Contributor

@lovo-h lovo-h left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! I left a few nit comments, but they were not blockers.

Test Instructions

  • 🟢 Check out with Woo Pre-Orders uninstalled.
    • Checked out with Bacs without issues.
  • 🟢 Test Pre-Orders that charge Upfront.
    • Checked out with Bacs without issues.
  • 🟢 Test Pre-Orders that charge Upon release.
    • Bacs is unavailable as a payment option in the checkout form (see image below).
      image

@asumaran asumaran enabled auto-merge (squash) March 7, 2025 00:05
@asumaran asumaran merged commit b696e41 into develop Mar 7, 2025
36 of 38 checks passed
@asumaran asumaran deleted the as-fix-pre-orders-charge-upon-release branch March 7, 2025 00:14
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