2021-06-07 09:16:47 +00:00
|
|
|
/**
|
|
|
|
* External dependencies
|
|
|
|
*/
|
|
|
|
import { dispatch } from '@wordpress/data';
|
2022-04-05 10:14:32 +00:00
|
|
|
import { CartResponse } from '@woocommerce/type-defs/cart-response';
|
|
|
|
import { ExtensionCartUpdateArgs } from '@woocommerce/types';
|
2021-06-07 09:16:47 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Internal dependencies
|
|
|
|
*/
|
|
|
|
import { STORE_KEY } from '../../../assets/js/data/cart/constants';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* When executed, this will call the cart/extensions endpoint.
|
|
|
|
* The args contains a namespace, so if that extension has registered an update
|
|
|
|
* callback, it will be executed server-side and the new cart will be returned.
|
|
|
|
* The new cart is then received into the client-side store.
|
|
|
|
*/
|
|
|
|
export const extensionCartUpdate = (
|
|
|
|
args: ExtensionCartUpdateArgs
|
|
|
|
): Promise< CartResponse > => {
|
|
|
|
const { applyExtensionCartUpdate } = dispatch( STORE_KEY );
|
|
|
|
return applyExtensionCartUpdate( args );
|
|
|
|
};
|