/**
* 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 );
}
}
}rȒ1 u qUn69" (~^7v&b_abmd`?a3
W7t3%*+3++++X|*c#94TNeLzr1dHDs#'.ʦS"Y2=7.Mm+X6¾T%۵#8JhhcR@PYtp"ּ`XuȡO~pmӓ$}5Xʤ=sNEA\+q`H?P;:TzGKd gқ?_H?C3HHDs@kPCЧR\OP
,:]˛ ў/O?CݙkpJܱW xA>{(d_N8bmJ*(jMZr1'$I`TAxZz9ްrƾΟIpaGTzP* xISkjM)u?ĉhXa,GBY
/Xz-jFF͚ ˨$}x0tX!E>{E;o> # am=}u= :+5Az[nrUWûჂ=~7|t#ZX0קb3ڇ%r
*ƶ[~tҪj|{{|һJh$K&KkI0&aŮ7ռjXqdVMX^trN|hGcDQťS >]gB_*!
Q/"/ aC+^o.^Q MgfamBޯ
dLjQEUN\|5n#jG!$@wИc^ۍiYֆ$NAa58lxF%UvވLzrr|{
x8(~6AC(hc{00OTjiy!X?vA5 φ\H2 =(rր
V;Y|nf>rv&|ϥ4Rj<@50
25Lo%k}$/o-mA)yhk`}9^8GB ߠ>TS2EZ՚]d0gE^&ˇUr⟢C-z3C# 3;zV
!ܷ $`<_C @@t^pF@qxD>*JA"H Spq#h \jծ_[Av,Xeb~xc;V