Commit f831491c66c for woocommerce
commit f831491c66cf51f6163c5c37a743b29ae6ab0a99
Author: Burak Pars Aydin <hi@burakaydin.net>
Date: Sat Mar 7 15:17:07 2026 +0300
Show correct heading for billing address when Local Pickup is selected (#58220)
* Show correct heading for billing address when Local Pickup is selected
* Refactor: Use shippingRates to reliably detect Local Pickup selection
* Add the changelog file
* Use hasSelectedLocalPickup from useShippingData directly
Instead of manually checking for 'pickup_location' method_id which
doesn't cover all local pickup methods, use the existing
hasSelectedLocalPickup property from useShippingData hook.
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
---------
Co-authored-by: Seghir Nadir <nadir.seghir@gmail.com>
Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
diff --git a/plugins/woocommerce/changelog/fix-58213 b/plugins/woocommerce/changelog/fix-58213
new file mode 100644
index 00000000000..bb8e23eadf8
--- /dev/null
+++ b/plugins/woocommerce/changelog/fix-58213
@@ -0,0 +1,4 @@
+Significance: minor
+Type: fix
+
+Fix - Show 'Billing address' instead of 'Billing and shipping address' when Local Pickup is selected and shipping is forced to the billing address.
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx
index c745279e096..8e4139ca5a8 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/frontend.tsx
@@ -4,7 +4,10 @@
import clsx from 'clsx';
import { withFilteredAttributes } from '@woocommerce/shared-hocs';
import { FormStep } from '@woocommerce/blocks-components';
-import { useCheckoutAddress } from '@woocommerce/base-context/hooks';
+import {
+ useCheckoutAddress,
+ useShippingData,
+} from '@woocommerce/base-context/hooks';
import { useSelect } from '@wordpress/data';
import { checkoutStore } from '@woocommerce/block-data';
@@ -37,14 +40,21 @@ const FrontendBlock = ( {
const { showBillingFields, forcedBillingAddress, useBillingAsShipping } =
useCheckoutAddress();
+ const { hasSelectedLocalPickup } = useShippingData();
+
if ( ! showBillingFields && ! useBillingAsShipping ) {
return null;
}
- title = getBillingAddresssBlockTitle( title, forcedBillingAddress );
+ title = getBillingAddresssBlockTitle(
+ title,
+ forcedBillingAddress,
+ hasSelectedLocalPickup
+ );
description = getBillingAddresssBlockDescription(
description,
- forcedBillingAddress
+ forcedBillingAddress,
+ hasSelectedLocalPickup
);
return (
<FormStep
diff --git a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/utils.tsx b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/utils.tsx
index 2d80654eb4d..ecca705e8f5 100644
--- a/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/utils.tsx
+++ b/plugins/woocommerce/client/blocks/assets/js/blocks/checkout/inner-blocks/checkout-billing-address-block/utils.tsx
@@ -10,10 +10,11 @@ import {
export const getBillingAddresssBlockTitle = (
title: string,
- forcedBillingAddress: boolean
+ forcedBillingAddress: boolean,
+ isLocalPickup: boolean
): string => {
- if ( forcedBillingAddress ) {
- // Returns default forced billing title when forced billing address is enabled and there is no title set.
+ if ( forcedBillingAddress && ! isLocalPickup ) {
+ // Returns the combined "Billing and shipping address" title only if forced billing is enabled and Local Pickup is not selected, and no custom title is set.
return title === DEFAULT_TITLE ? DEFAULT_FORCED_BILLING_TITLE : title;
}
// Returns default title when forced billing address is disabled and there is no title set.
@@ -22,10 +23,11 @@ export const getBillingAddresssBlockTitle = (
export const getBillingAddresssBlockDescription = (
description: string,
- forcedBillingAddress: boolean
+ forcedBillingAddress: boolean,
+ isLocalPickup: boolean
): string => {
- if ( forcedBillingAddress ) {
- // Returns default forced billing description when forced billing address is enabled and there is no description set.
+ if ( forcedBillingAddress && ! isLocalPickup ) {
+ // Returns the combined "Billing and shipping address" description if forced billing is enabled, Local Pickup is not selected, and the default description is used.
return description === DEFAULT_DESCRIPTION
? DEFAULT_FORCED_BILLING_DESCRIPTION
: description;