Automattic\WooCommerce\Blocks\BlockTypes
Checkout::hydrate_from_api() protected WC 1.0
Hydrate the checkout block with data from the API.
{} It's a method of the class: Checkout{}
No Hooks.
Return
Null. Nothing.
Usage
// protected - for code of main (parent) or child class $result = $this->hydrate_from_api( $data_registry );
- $data_registry(AssetDataRegistry) (required)
- Data registry instance.
Code of Checkout::hydrate_from_api() Checkout::hydrate from api WC 5.0.0
protected function hydrate_from_api( AssetDataRegistry $data_registry ) {
// Print existing notices now, otherwise they are caught by the Cart
// Controller and converted to exceptions.
wc_print_notices();
if ( ! $data_registry->exists( 'cartData' ) ) {
$data_registry->add( 'cartData', WC()->api->get_endpoint_data( '/wc/store/cart' ) );
}
if ( ! $data_registry->exists( 'checkoutData' ) ) {
add_filter( 'woocommerce_store_api_disable_nonce_check', '__return_true' );
$data_registry->add( 'checkoutData', WC()->api->get_endpoint_data( '/wc/store/checkout' ) );
remove_filter( 'woocommerce_store_api_disable_nonce_check', '__return_true' );
}
}