/** * Helper functions for interacting with the Store API. * * This file is autoloaded via composer.json. */ use Automattic\WooCommerce\StoreApi\StoreApi; use Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema; if ( ! function_exists( 'woocommerce_store_api_register_endpoint_data' ) ) { /** * Register endpoint data under a specified namespace. * * @see Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::register_endpoint_data() * * @param array $args Args to pass to register_endpoint_data. * @returns boolean|\WP_Error True on success, WP_Error on fail. */ function woocommerce_store_api_register_endpoint_data( $args ) { try { $extend = StoreApi::container()->get( ExtendSchema::class ); $extend->register_endpoint_data( $args ); } catch ( \Exception $error ) { return new \WP_Error( 'error', $error->getMessage() ); } return true; } } if ( ! function_exists( 'woocommerce_store_api_register_update_callback' ) ) { /** * Add callback functions that can be executed by the cart/extensions endpoint. * * @see Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::register_update_callback() * * @param array $args Args to pass to register_update_callback. * @returns boolean|\WP_Error True on success, WP_Error on fail. */ function woocommerce_store_api_register_update_callback( $args ) { try { $extend = StoreApi::container()->get( ExtendSchema::class ); $extend->register_update_callback( $args ); } catch ( \Exception $error ) { return new \WP_Error( 'error', $error->getMessage() ); } return true; } } if ( ! function_exists( 'woocommerce_store_api_register_payment_requirements' ) ) { /** * Registers and validates payment requirements callbacks. * * @see Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::register_payment_requirements() * * @param array $args Args to pass to register_payment_requirements. * @returns boolean|\WP_Error True on success, WP_Error on fail. */ function woocommerce_store_api_register_payment_requirements( $args ) { try { $extend = StoreApi::container()->get( ExtendSchema::class ); $extend->register_payment_requirements( $args ); } catch ( \Exception $error ) { return new \WP_Error( 'error', $error->getMessage() ); } return true; } } if ( ! function_exists( 'woocommerce_store_api_get_formatter' ) ) { /** * Returns a formatter instance. * * @see Automattic\WooCommerce\StoreApi\Schemas\ExtendSchema::get_formatter() * * @param string $name Formatter name. * @return Automattic\WooCommerce\StoreApi\Formatters\FormatterInterface */ function woocommerce_store_api_get_formatter( $name ) { return StoreApi::container()->get( ExtendSchema::class )->get_formatter( $name ); } } }rG%8,3h\HI=#ZKˁS. -4]!3~=1O8UW4.$A{f2R]GlnI8sO??ĥiO{4c!%ք'o>3ܣ3vR9sAX!BܱɉK8:5E]vҒX\Ǜ'?#e2 2 C_5?`8y:Nz ٘fV똼cF[ϱ8QCջa}/C=7 1aÎ\ia9cz Ⴜkb <V!iH kD³N*# h, 6 څUgy^Ii?o;i4S3ah@ |P%[S@ݺmde!<А AUwP{@ߞ\x*j y#~L>1B 1nYc@ *.I?h؎KC3qT}^lɚ'$YFc0l;Y:Xn\TT[9҄55D}f]CVw Y]խ7w|ר*(g !|< ,V9!bh5xHƠߋOXpҫf~7ț#ZKirc< ]qč[ujK^5v/`!'"рa"G:3DgQcs) ޯQ7b_ǂ h^<