get_var( $wpdb->prepare( "SELECT currency FROM {$orderTable} WHERE id = %d", $orderId ) ); } else { $currency = get_post_meta( $orderId, self::KEY_LEGACY_CURRENCY, true ); } return $currency ?: null; } ); return $getCurrency( $orderId ); } /** * @param int $orderId * * @return string|null */ private static function getCurrencyFromOrderObject( $orderId ) { $isNotAutoDraft = pipe( invoke( 'get_status' ), Relation::equals( 'auto-draft' ), Logic::not() ); return Maybe::fromNullable( wc_get_order( $orderId ) ) ->filter( $isNotAutoDraft ) ->map( invoke( 'get_currency' ) ) ->getOrElse( null ); } /** * @param int $orderId * @param string $currency * * @return void */ public static function setCurrency( $orderId, $currency ) { Maybe::fromNullable( wc_get_order( $orderId ) ) ->map( Fns::tap( invoke( 'set_currency' )->with( $currency ) ) ) ->map( invoke( 'save' ) ); } /** * Checks if the current screen is an admin screen for WooCommerce New Order (Legacy or HPOS). * * @return bool */ public static function isOrderCreateAdminScreen(): bool { return COTHelper::isOrderCreateAdminScreen() || LegacyHelper::isOrderCreateAdminScreen(); } /** * Checks if the current screen is an admin screen for list of WooCommerce orders (Legacy or HPOS). * * @return bool */ public static function isOrderListAdminScreen(): bool { return COTHelper::isOrderListAdminScreen() || LegacyHelper::isOrderListAdminScreen(); } /** * Checks if the current screen is an admin screen for WooCommerce Edit Order (Legacy or HPOS). * * @return bool */ public static function isOrderEditAdminScreen(): bool { return COTHelper::isOrderEditAdminScreen() || LegacyHelper::isOrderEditAdminScreen(); } }