product_factory->get_product( $productId ); if ( $product instanceof WC_Product ) { return $product; } return null; } /** * Gets product by post or post id. * * @param mixed $theProduct Post id or object. * * @return false|WC_Product|null */ public function getProduct( $theProduct ) { return wc_get_product( $theProduct ); } public function isCheckout(): bool { return is_checkout(); } public function featuresUtilDeclareCompatibility( string $featureId, string $pluginFile, bool $positiveCompatibility = true ): void { FeaturesUtil::declare_compatibility( $featureId, $pluginFile, $positiveCompatibility ); } public function storeApiRegisterUpdateCallback( array $args ): void { woocommerce_store_api_register_update_callback( $args ); } public function shipToBillingAddressOnly(): bool { return wc_ship_to_billing_address_only(); } public function shippingGetPackages(): array { return WC()->shipping()->get_packages(); } public function addNotice( string $message, string $noticeType ): void { wc_add_notice( $message, $noticeType ); } /** * @return WC_Logger|WC_Logger_Interface */ public function getLogger() { return wc_get_logger(); } /** * @return array * }> */ public function countriesGetContinents(): array { return WC()->countries->get_continents(); } /** * @param array{contents: array>, contents_cost: float, applied_coupons: array, user: array{ID: int}, destination: array, cart_subtotal: float, packetery_payment_method: mixed, rates: array} $package * * @return WC_Shipping_Zone */ public function shippingZonesGetZoneMatchingPackage( array $package ): WC_Shipping_Zone { return WC_Shipping_Zones::get_zone_matching_package( $package ); } public function hasBlockInPage( int $page, string $blockName ): bool { return WC_Blocks_Utils::has_block_in_page( $page, $blockName ); } /** * @param string $objectType * * @return WC_Data_Store|WC_Shipping_Zone_Data_Store_Interface */ public function dataStoreLoad( string $objectType ): object { return WC_Data_Store::load( $objectType ); } /** * Returns WC_Abstract_Order[] * * @param array $args * * @return array */ public function getOrdersWithoutPagination( array $args ): array { $results = wc_get_orders( $args ); if ( is_array( $results ) ) { return $results; } if ( $results instanceof stdClass && isset( $results->orders ) && is_array( $results->orders ) ) { return $results->orders; } return []; } public function adminStatusStatusReport(): void { WC_Admin_Status::status_report(); } public function loggingUtilGetLogDirectory( bool $createDir = true ): ?string { if ( class_exists( LoggingUtil::class ) === false ) { return null; } return LoggingUtil::get_log_directory( $createDir ); } }