diff --git a/includes/Admin/Orders/Single_Order.php b/includes/Admin/Orders/Single_Order.php index f2fa3dfb..70aa0fd9 100644 --- a/includes/Admin/Orders/Single_Order.php +++ b/includes/Admin/Orders/Single_Order.php @@ -1,14 +1,49 @@ add_available_gateways(); + } + + /** + * We need to add the POS gateways to the available gateways for the edit order dropdown. + * It's possible another plugin could just re-init after us, but this will work for most cases. + */ + public function add_available_gateways() { + if ( WC()->payment_gateways() ) { + $payment_gateways = WC()->payment_gateways->payment_gateways; + $settings = woocommerce_pos_get_settings( 'payment_gateways' ); + + // Add POS gateways to the available gateways for the edit order dropdown. + foreach ( $payment_gateways as $gateway ) { + if ( isset( $settings['gateways'][ $gateway->id ] ) && $settings['gateways'][ $gateway->id ]['enabled'] ) { + $gateway->enabled = 'yes'; + } + } + + // Directly set the modified gateways back to the WooCommerce Payment Gateways instance + WC()->payment_gateways->payment_gateways = $payment_gateways; + } } /** diff --git a/includes/Gateways.php b/includes/Gateways.php index 567f981f..e5348ac6 100644 --- a/includes/Gateways.php +++ b/includes/Gateways.php @@ -56,20 +56,20 @@ public function payment_gateways( array $gateways ) { * * - NOTE: lots of plugins/themes call this filter and I can't guarantee that $gateways is an array * - * @param null|array $gateways + * @param null|array $gateways The available payment gateways. * - * @return null|array + * @return null|array The available payment gateways. */ public function available_payment_gateways( ?array $gateways ): ?array { - // early exit + // early exit. if ( ! woocommerce_pos_request() ) { return $gateways; } - // use POS settings + // use POS settings. $settings = woocommerce_pos_get_settings( 'payment_gateways' ); - // Get all payment gateways + // Get all payment gateways. $all_gateways = WC()->payment_gateways->payment_gateways; $_available_gateways = array(); diff --git a/readme.txt b/readme.txt index a2b6b1e5..aa39317c 100644 --- a/readme.txt +++ b/readme.txt @@ -63,11 +63,12 @@ There is more information on our website at [https://wcpos.com](https://wcpos.co == Changelog == -= 1.4.11 - 2024/02/27 = += 1.4.11 - 2024/03/XX = * Fix: regression in tax calculation when POS settings are different to Online settings * Fix: regression in product variation images, use 'medium' sized product image instead of full size * Fix: remove POS Only products from frontend WC REST API response * Fix: generic get meta method should not be used for '_create_via' +* Fix: add enabled POS gateways to the Order Edit select input * Fix: other minor PHP warnings = 1.4.10 - 2024/01/23 =