Automattic / woocommerce-services

WooCommerce Services is a feature plugin that integrates hosted services into WooCommerce (3.0+), and currently includes automated tax rates and the ability to purchase and print USPS shipping labels.
GNU General Public License v2.0
107 stars 20 forks source link

Shipping Phone compatibility issue with WC core phone field #2768

Open kloon opened 1 month ago

kloon commented 1 month ago

There seems to be a compatibility issue with the phone field being added in WCS&T and the phone field that can be enabled via WC core.

We need to ensure the two fields work together, ie the one added via WCS&T should not duplicated the field but only add it id the core field is not enabled, and if it is enabled only modifying the props to make the validation work and make it a required field.

The two methods in question are add_shipping_phone_to_checkout and add_shipping_phone_to_order_fields

To reproduce the issue enable the WC core phone field, en at checkout you will now see two phone fields.

Let's also port this fix to WC Shipping.

dustinparker commented 1 month ago

Hey @kloon,

The Woo Services extension already has a check in it to ensure the field is not added if it already exists. I did some testing to see how this works alongside other plugins that may be enabling the shipping phone field via filter and never got a duplicate field. I tested various filter priorities with 2 other plugins and can't seem to replicate the issue in the checkout or admin order screen. Maybe I'm missing part of the context?

pierorocca commented 1 month ago

Thanks so much for having a look. We added a check and a merchant notification in WooPayments to see if plugins are adding custom fields to the checkout form, which can cause hard failures with Apple Pay and Google Pay which don’t work with mandatory custom fields. After deployment I noticed that I’d always see the warning notification and traced it back to the shipping extension.

@FangedParakeet could you add the pertinent technical details of the WooPayments implementation so we can see where either of us could help each other out?

pierorocca commented 1 month ago

and if it is enabled only modifying the props to make the validation work and make it a required field.

Is this true today? Despite having the plugin enabled, phone number always appears as optional and will pass validation.

FangedParakeet commented 1 month ago

The Woo Services extension already has a check in it to ensure the field is not added if it already exists. I did some testing to see how this works alongside other plugins that may be enabling the shipping phone field via filter and never got a duplicate field.

This was my understanding of the filter from the shipping perspective: I don't believe this is having any negative effects on functionality.

After deployment I noticed that I’d always see the warning notification and traced it back to the shipping extension.

This is down to our own aggressive implementation, which currently checks whether any other extension is adding a custom field under any circumstances and currently flags Woo Shipping unnecessarily for doing so AFAIA.