Skip to content

Fix fulfillment type determination logic#470

Open
Octobr26 wants to merge 4 commits intowoocommerce:trunkfrom
Octobr26:patch-1
Open

Fix fulfillment type determination logic#470
Octobr26 wants to merge 4 commits intowoocommerce:trunkfrom
Octobr26:patch-1

Conversation

@Octobr26
Copy link
Copy Markdown

@Octobr26 Octobr26 commented Mar 9, 2026

All Submissions:

  • Does your code follow the WooCommerce Sniffs variant of WordPress coding standards?
  • Have you written new tests for your changes, as applicable?
  • Have you successfully run tests with your changes locally?
  • Will this change require new documentation or changes to existing documentation?

Changes proposed in this Pull Request:

This PR fixes Local Pickup orders being mapped to shipping semantics during Square order sync.

Changes:

  1. Fulfillment type mapping now treats orders as SHIPMENT only when a non-local_pickup shipping method is present.
  2. local_pickup methods are excluded from Square shipping line items.
  3. local_pickup methods are excluded from Square shipping service charges.
  4. Added a shared helper (is_local_pickup_method) so pickup detection logic is centralized and reused across all relevant paths.

This ensures Local Pickup orders are sent to Square as pickup orders, not shipment orders.
This also addresses the Local Pickup sync bug tracked in #465.
Closes #465 .

Steps to test the changes in this Pull Request:

  1. Enable bidirectional order fulfillment sync in WooCommerce Square settings, then place an order using standard WooCommerce Local Pickup (method_id: local_pickup) with one or more line items.
  2. Inspect the Square order created for that Woo order and verify fulfillment type is PICKUP (not SHIPMENT), and verify Local Pickup is not sent as a shipping line item/service charge.
  3. Place a second order using a non-pickup shipping method (for example flat rate) and verify fulfillment type is SHIPMENT and shipping data is present as expected.
  4. Repeat both order types with coupon/tax scenarios to confirm no regression in totals/itemization behavior.

Changelog entry

Fix - Correct Local Pickup order sync mapping so Square receives pickup fulfillments and does not treat Local Pickup as shipping lines/service charges.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Refactors how WooCommerce Square determines and serializes order fulfillment and shipping data so that Local Pickup (local_pickup) orders sync to Square as pickup fulfillments instead of shipment fulfillments (addressing #465).

Changes:

  • Determine fulfillment type as SHIPMENT only when a non-local_pickup shipping method is present.
  • Exclude local_pickup methods from Square “shipping” line items and shipping service charges.
  • Centralize pickup detection in a shared is_local_pickup_method() helper.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

You can also share your feedback on Copilot code review. Take the survey.

Comment thread includes/Gateway/API/Requests/Orders.php
Comment thread includes/Gateway/API/Requests/Orders.php
Comment thread includes/Gateway/API/Requests/Orders.php
Comment thread includes/Gateway/API/Requests/Orders.php Outdated
Copy link
Copy Markdown
Collaborator

@faisal-alvi faisal-alvi left a comment

Choose a reason for hiding this comment

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

@Octobr26 Thanks for the fix. I have a concern: Local pickup is fully removed from both line items and service charges. When a store charges for pickup (e.g. $2.99), that amount is no longer sent to Square, so WooCommerce and Square totals can mismatch.

There’s also some Copilot-reported feedback on this PR; it would be good to look into that, too, when you have a chance. Thanks again!

@Octobr26 Octobr26 requested a review from faisal-alvi March 12, 2026 05:06
@Octobr26 Octobr26 changed the title Refactor fulfillment type determination logic Fix fulfillment type determination logic Mar 12, 2026
@vikrampm1 vikrampm1 added this to the Future Release milestone Mar 18, 2026
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.

Orders sync without items when bidirectional order fulfillment sync is enabled

4 participants