$value ) { // @codingStandardsIgnoreStart if ( is_int( $value ) ) { $_COOKIE[ $key ] = (string) $value; } // @codingStandardsIgnoreEnd } } /** * Gets WooCommerce version. * * @return string|null */ public static function getWooCommerceVersion(): ?string { if ( false === file_exists( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php' ) ) { return null; } $version = get_file_data( WP_PLUGIN_DIR . '/woocommerce/woocommerce.php', [ 'Version' => 'Version' ], 'plugin' )['Version']; if ( ! $version ) { return null; } return $version; } /** * Renders string. * * @param string $string String to render. * * @return void */ public static function renderString( string $string ): void { // phpcs:ignore WordPress.Security.EscapeOutput.OutputNotEscaped echo $string; } /** * Gets country from WC order. * * @param \WC_Order $wcOrder WC order. * * @return string May be empty. */ public static function getWcOrderCountry( \WC_Order $wcOrder ): string { $country = $wcOrder->get_shipping_country(); if ( empty( $country ) ) { $country = $wcOrder->get_billing_country(); } return strtolower( $country ); } /** * Tells if High Performance Order Storage is enabled. * * @return bool */ public static function isHposEnabled(): bool { if ( false === class_exists( 'Automattic\\WooCommerce\\Utilities\\OrderUtil' ) ) { return false; } if ( false === method_exists( OrderUtil::class, 'custom_orders_table_usage_is_enabled' ) ) { return false; } return OrderUtil::custom_orders_table_usage_is_enabled(); } /** * Converts all float values within an array to strings. * * @param array $array Array with parameters. * * @return array */ public static function convertArrayFloatsToStrings( array $array ): array { array_walk_recursive( $array, static function ( &$item ) { if ( is_float( $item ) ) { $item = (string) $item; } } ); return $array; } }