get_id() ); return $check; }, PHP_INT_MAX, 2 ); add_action( 'patchwork_split_completed', [ Stock::class, 'clear_context' ], 1 ); add_filter( 'patchwork_split_can_merge', [ __CLASS__, 'can_merge' ], 10, 3 ); } public static function copy_location( $child, $order ): void { if ( ! $child instanceof \WC_Order || ! $order instanceof \WC_Order ) return; $id = Orders::get( $order ); if ( $id ) $child->update_meta_data( Orders::META, $id ); } public static function can_merge( $result, $primary, $source ) { if ( $result !== null || ! $primary instanceof \WC_Order || ! $source instanceof \WC_Order ) return $result; $a = Orders::location_of( $primary ); $b = Orders::location_of( $source ); if ( $a && $b && $a !== $b ) { return new \WP_Error( 'patchwork_locations_merge', sprintf( /* translators: %s: location name */ __( 'It\'s for a different location (%s).', 'patchwork-locations' ), Locations::name( $b ) ) ); } return $result; } }