Repository navigation
Set up checkout and publish the shop after the Commerce Partner Integration install completes - #4090
Open
jczhuoMeta wants to merge 5 commits into
Open
jczhuoMeta wants to merge 5 commits into
jczhuoMeta wants to merge 5 commits into
Conversation
Contributor
📦 Latest Plugin BuildBuilt at: 2026-11-05T10:26:11Z Download: Click here to download the plugin To download: Click the link above → Scroll to bottom → Download "facebook-for-woocommerce" artifact |
jczhuoMeta
marked this pull request as ready for review
October 13, 2026 22:51
|
@jczhuoMeta has imported this pull request. If you are a Meta employee, you can view this in D125257085. |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #4090 +/- ##
=======================================
Coverage ? 11.08%
Complexity ? 6140
=======================================
Files ? 236
Lines ? 20840
Branches ? 0
=======================================
Hits ? 2311
Misses ? 18529
Partials ? 0
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ration install completes
Onboarding through Facebook Login for Business no longer sets up checkout
on Meta's side, so the plugin does it once finalize-install succeeds. It
calls POST /{commerce_merchant_settings_id} with checkout_config: the
store's WooCommerce /checkout-link/ URL, the integration's country from
the finalize-install response (the store's base country when it has
none), and publish_shop set so the shop is published.
The call runs only after a successful finalize-install, never fails the
install, and logs its outcome. It is skipped without a Commerce Merchant
Settings ID, without a country, or on WooCommerce older than 10.0, which
does not serve /checkout-link/.
Stores without debug logging only see the outcome log, so record the checkout URL there too; it shows what was sent to Meta, including its scheme and host.
…gs ID Return before the Graph call and the outcome log, so stores without a CMS no longer queue a 'skipped' checkout setup log. The country and WooCommerce version skips still log 'skipped'.
/checkout-link/ is a WooCommerce front-end rewrite rule. site_url() points inside the WordPress directory on subdirectory installs, and the rule never routes without pretty permalinks, so either case would publish the shop with a checkout URL that 404s. Use home_url(), skip (logged as 'skipped') on plain permalinks, and log whether pretty permalinks are on.
The store owns its country: the plugin already pushes WC()->countries->get_base_country() to the Commerce Partner Integration as country_code. Reading it back from the finalize-install response was circular, so use the base country directly and drop the response's country_code parsing.
vahidkay-meta
force-pushed
the
feature/fbl4b-checkout-setup
branch
from
November 5, 2026 10:25
54bf699 to
99452ae
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
When a store onboards through Facebook Login for Business, Meta no longer sets up checkout for it during onboarding. The plugin now does this itself after the Commerce Partner Integration (CPI) install completes.
Once
POST /commerce-partner-integrations/finalize-installsucceeds,Settings\Handler::handle_finalize_install()calls the Graph API once:/checkout-link/endpoint, the same URL Meta's checkout already sends buyers to (see Remove unused /fb-checkout endpoint; Meta checkout calls WooCommerce's /checkout-link (WC 10.0+) #4082). Meta appends the cart to the query string. It is built fromhome_url(), the site address, because/checkout-link/is a front-end rewrite rule.site_url()would point inside the WordPress directory on stores that install WordPress in a subdirectory.WC()->countries->get_base_country()). The store is the source of truth: this is the same value the plugin already pushes to the CPI ascountry_code, so it is not read back from Meta.publish_shop: true: Meta also publishes the shop. Without it, the endpoint only publishes for some partner platforms.Skipped quietly (no call, no log) when:
Skipped and logged as
skippedwhen:/checkout-link/is a rewrite rule and does not route without pretty permalinks;/checkout-link/does not exist there.Failure handling: a failed call never fails the install. Both Graph errors and transport errors are caught, and every attempted outcome is logged as
commerce_merchant_settings_checkout_setup(success,skippedorfailed) with the CMS ID, country, checkout URL sent, whether pretty permalinks are on, WooCommerce version and any error. There is no automatic retry.Known limitation: like any other Graph call made through
API, a 200-range permission error from this request sets thewc_facebook_connection_invalidflag.Added
API\CommerceMerchantSettings\Checkout\RequestAPI::set_up_checkout()Internal tracking: T292693512
Type of change
Checklist
Changelog entry
Set up checkout and publish the shop after the Commerce Partner Integration install completes.
Test Plan
Automated
New cases in
HandlerFinalizeInstallTest. They intercept the Graph request, so the real request payload is asserted.POST /{cms_id}withcheckout_config(home_url('/checkout-link/'), the store's base country,publish_shop: true) and logssuccess./wpand the site address at the root, the checkout URL uses the site address.skippedis logged withpretty_permalinks: false.country_code, and checkout is skipped and logged when the store has no base country.failedwith the error, and the install still returns 200.Other checks:
phpcs.xml.dist), PHPCompatibilityWP (PHP 7.4+),php -landgit diff --check: clean.main.Manual verification (required before release)
On a test store allowlisted for Facebook Login for Business onboarding, running WooCommerce 10.0+ with debug logging enabled:
POST /{commerce_merchant_settings_id}withcheckout_configand acommerce_merchant_settings_checkout_setuplog withsuccess.<site>/checkout-link/and that the Facebook and Instagram shops are published.QA results
Local WordPress store (WordPress 7.1.2, WooCommerce 11.1.2, PHP 8.2.30), 2026-10-13.
These results are from the first revision. Since then the checkout URL uses
home_url(), the country is the store's base country, plain permalinks are skipped, and a missing CMS ID is skipped without a log. The manual steps above will be re-run on the current head. The PHP debug log had no new warnings or fatal errors during any of the checks below, including heartbeats run through WP-Cron.POST /{cms_id}was sent with{"checkout_config":{"checkout_url":"http://localhost:10005/checkout-link/","country_code":"US","publish_shop":true}}and Meta returned200 {"success":true}.commerce_merchant_settings_checkout_setupwas logged assuccess, with the checkout URL, the country and the WooCommerce version.checkout_config(US)ishttp://localhost:10005/checkout-link/,offsite_iab_checkout_enabled_countriesis["US"], and the Facebook shop sales channel isENABLED./checkout-link/?products=<id>:1redirects (302) to/checkout/with the cart filled.Screenshots
Not applicable; this change has no user-interface impact.