Skip to content

Commit 9cbaa97

Browse files
committed
Bug #59571: sync billing address values in blocks checkout
1 parent a62ce60 commit 9cbaa97

File tree

7 files changed

+22
-8
lines changed

7 files changed

+22
-8
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<?php return array('dependencies' => array('react', 'wc-blocks-checkout', 'wc-blocks-components', 'wc-blocks-data-store', 'wc-settings', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '7f123088717075ee9ec5');
1+
<?php return array('dependencies' => array('react', 'wc-blocks-checkout', 'wc-blocks-components', 'wc-blocks-data-store', 'wc-settings', 'wp-data', 'wp-element', 'wp-i18n'), 'version' => '5b3237eb895ec83977a0');

build/shipping-address-autocomplete-intl-frontend.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

postcode-eu-address-validation.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Plugin Name: Postcode.eu Address Validation
44
* Plugin URI: https://www.postcode.eu/products/address-api/implementation
55
* Description: Address autocomplete and validation using the Postcode.eu API.
6-
* Version: 2.4.0
6+
* Version: 2.4.1
77
* Author: Postcode.nl
88
* Author URI: https://www.postcode.nl
99
* License: FreeBSD license

readme.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
=== Postcode.eu Address Validation ===
22
Contributors: postcodenl
33
Tags: address validation, address autocomplete, postcode api, address api, postcode check
4-
Stable tag: 2.4.0
4+
Stable tag: 2.4.1
55
Tested up to: 6.7
66
License: FreeBSD license
77
License URI: https://directory.fsf.org/wiki/License:BSD-2-Clause-FreeBSD
@@ -86,6 +86,9 @@ For more details on the Postcode.eu API and how to obtain an account, please vis
8686

8787
== Changelog ==
8888

89+
= 2.4.1 =
90+
* Fixed billing address values not synced from shipping address with use-shipping-as-billing option enabled.
91+
8992
= 2.4.0 =
9093
* Add support for blocks checkout. Note that this currently only works with the single address input field. Autocomplete based on Dutch postcode and house number will be supported in a future version.
9194

src/PostcodeNl/AddressAutocomplete/Main.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
class Main
1212
{
1313
/** @var string The version number of the plugin should be equal to the commented version number in ../../../postcode-eu-address-validation.php */
14-
public const VERSION = '2.4.0';
14+
public const VERSION = '2.4.1';
1515

1616
/** @var string Path to the plugin directory */
1717
public static $pluginDirPath;

src/blocks/billing-address-autocomplete-intl/block.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { CART_STORE_KEY, CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
33
import AutocompleteContainer from '../../components/address-autocomplete-intl/container';
44

55
const Block = () => {
6-
const useShippingAsBilling = useSelect(select => select(CHECKOUT_STORE_KEY).getUseShippingAsBilling() , []),
6+
const useShippingAsBilling = useSelect(select => select(CHECKOUT_STORE_KEY).getUseShippingAsBilling(), []),
77
{billingAddress} = useSelect(select => select(CART_STORE_KEY).getCustomerData(), []),
88
{setBillingAddress} = useDispatch(CART_STORE_KEY);
99

src/blocks/shipping-address-autocomplete-intl/block.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,21 @@
11
import { useSelect, useDispatch } from '@wordpress/data';
2+
import { useEffect } from '@wordpress/element';
23
import { CART_STORE_KEY } from '@woocommerce/block-data';
4+
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
35
import AutocompleteContainer from '../../components/address-autocomplete-intl/container';
46

57
const Block = () => {
6-
const {shippingAddress} = useSelect(select => select(CART_STORE_KEY).getCustomerData(), []),
7-
{setShippingAddress} = useDispatch(CART_STORE_KEY);
8+
const useShippingAsBilling = useSelect(select => select(CHECKOUT_STORE_KEY).getUseShippingAsBilling(), []),
9+
{shippingAddress} = useSelect(select => select(CART_STORE_KEY).getCustomerData(), []),
10+
{setShippingAddress, setBillingAddress} = useDispatch(CART_STORE_KEY);
11+
12+
useEffect(() => {
13+
if (useShippingAsBilling)
14+
{
15+
// Billing address needs to be synced with shipping address after calling `setShippingAddress`.
16+
setBillingAddress({...shippingAddress});
17+
}
18+
}, [shippingAddress]);
819

920
return (
1021
<AutocompleteContainer

0 commit comments

Comments
 (0)