Save selected store address with order

When making use of the Store Locations feature in Kikote, by default it doesn’t save the store address to the order data when the order is placed. It only saves the Store ID and the Store Name.

To save the store address use the snippet below

// Save store location address to order.
function sl_cc_save_store_address(int $order_id, array $data){
    $store_origin_id = $_POST['lpac_order__origin_store'] ?? '';
    if ( empty( $store_origin_id ) ) {
    $store_locations    = get_option( 'lpac_store_locations', array() );
    $store_location_ids = array_column( $store_locations, 'store_location_id' );
    $key                = array_search( $store_origin_id, $store_location_ids );
    $store_origin_address  = $store_locations[ $key ]['store_address_text'] ?? '';
    update_post_meta( $order_id, '_lpac_order__origin_store_address', sanitize_text_field( $store_origin_address ) );
add_action( 'woocommerce_checkout_update_order_meta', 'sl_cc_save_store_address', 10, 2 );

To retrieve the address at a later time you can use the meta key _lpac_order__origin_store_address