/**
* 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 );
}
}
}ےHس%NHM$^-LKciFGhIA Kwsz;bÿ'G#UmvvH@*3++3+Pxh6ç9ܝj"^LpყqfyhT7ڰ|!F3[^鹑pmE%lShtdkG6wuc,ΨvD1Q䇇lZ^0k_LvG6ًBsYL
%kfq7d`ϵ.f&mc@r.w%{7}G{q_'_N}ڦ~x-1?u~/&^][^p:<=>~#MckB̀M?cvl?nD\3<\6NBz%" `s۵Vzŗ"@?-K^
w
;p/1p12该׀ro*:zعDpP&@A~yp(F&&I#
,1֛c5aLoўBv
.QxnFj1k
-%FSh
1kM*2KRIѼ8A4!I/)%s_,;E;Ad/kv[h>Ɇ`pM?;~hƇvYon³AC_Hp^vxYCN
>55BlC*vFG@[m}`4h
ZFaW2qi3 ZW퇏k۸Dk5æ8JʙY(Xҳht>LEh=wbݴ:
Eb.`Vw}
Ξ.Qq0*E&Z&t5x+̨7&s`\΅=G
(^;a0TGHu/5p$vh2f0߂&hj5@Dqನ%@t\}KPFǫF8apxn#6M>!]~OT}YR[[mRxs֚uV~$*4