Make sure orders are always saved with addresses indexes set (#40332)
* Make sure orders are saved with addresses indexes set. * Add changelog
This commit is contained in:
parent
3544ef300f
commit
f446315f32
|
@ -0,0 +1,4 @@
|
||||||
|
Significance: patch
|
||||||
|
Type: fix
|
||||||
|
|
||||||
|
Always generate address metadata indexes for HPOS orders.
|
|
@ -2580,8 +2580,10 @@ FROM $order_meta_table
|
||||||
private function update_address_index_meta( $order, $changes ) {
|
private function update_address_index_meta( $order, $changes ) {
|
||||||
// If address changed, store concatenated version to make searches faster.
|
// If address changed, store concatenated version to make searches faster.
|
||||||
foreach ( array( 'billing', 'shipping' ) as $address_type ) {
|
foreach ( array( 'billing', 'shipping' ) as $address_type ) {
|
||||||
if ( isset( $changes[ $address_type ] ) ) {
|
$index_meta_key = "_{$address_type}_address_index";
|
||||||
$order->update_meta_data( "_{$address_type}_address_index", implode( ' ', $order->get_address( $address_type ) ) );
|
|
||||||
|
if ( isset( $changes[ $address_type ] ) || ( is_a( $order, 'WC_Order' ) && empty( $order->get_meta( $index_meta_key ) ) ) ) {
|
||||||
|
$order->update_meta_data( $index_meta_key, implode( ' ', $order->get_address( $address_type ) ) );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue