Skip to content

Conversation

strangerkir
Copy link
Collaborator

@strangerkir strangerkir commented Aug 8, 2025

Ticket: PCP-4220, also PCP-1546 and PCP-952.


Description

Two filters added:
woocommerce_paypal_payments_shipping_preference and woocommerce_paypal_payments_shipping_preference.

There was a problem with disabled shipping fields. If in any way some required shipping field is disabled, PayPal returned an error (e.g. MISSING_SHIPPING_ADDRESS or MISSING SHIPPING_CITY). This happened because shipping_preference was set to SET_PROVIDED_ADDRESS, which made PayPal expect shipping fields.

It was decided not to make changes in how the plugin behaves, but to add filters to let merchants deal with this problem if they manipulate checkout fields.

Example code to fix MISSING_* error:

//Disable PayPal expectaion for shipping fields.
add_filter('woocommerce_paypal_payments_shipping_preference', fn() => 'NO_SHIPPING');

//Prevent sending shipping fields from order and cart
add_filter('woocommerce_paypal_payments_shipping_needed', '__return_false');

I'm attaching the same code as a plugin.
paypal_disable_shipping.zip

Steps to Test

  1. Install and activate the Flexible Checkout Fields plugin.
  2. Go to the Flexible Checkout Fields plugin settings, select the Shipping sub tab and disable Street Address field (see screenshot).
  3. Make sure shipping is enabled.
  4. Go to the classic checkout with any physical product in cart and complete checkout using Pay with PayPal button.
  5. Observe an error MISSING_SHIPPING_ADDRESS.
  6. Install and activate plugin attached to this PR.
  7. Go to the classic checkout and try to pay again, the error shouldn't happen anymore.
flexible-checkout-fields-disable-shipping-address

To merchants, who has this error we might recommend the snippet above, but not the plugin. We would need to add author and other details before providing it.

Documentation

  • This PR needs documentation (has the "Documentation" label).

Changelog Entry

Added filters for fixing MISSING_%field_name% checkout error when some shipping fields are missing.

Copy link
Collaborator

@Narek13 Narek13 left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks

@strangerkir strangerkir changed the base branch from trunk to develop August 19, 2025 12:43
@Dinamiko Dinamiko merged commit 1e84908 into develop Sep 8, 2025
11 checks passed
@Dinamiko Dinamiko deleted the PCP-4220-fix-missing-shipping-address-with-flexible-checkout-fields branch September 8, 2025 12:09
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.

3 participants