2020-02-18 23:06:37 +00:00
/ * *
* External dependencies
* /
import { __ } from '@wordpress/i18n' ;
2021-06-29 14:04:24 +00:00
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings' ;
2021-03-10 15:03:26 +00:00
import { CartResponse } from '@woocommerce/types' ;
2021-04-22 11:37:27 +00:00
import { getSetting } from '@woocommerce/settings' ;
2020-02-18 23:06:37 +00:00
/ * *
* Internal dependencies
* /
2020-03-13 13:41:59 +00:00
import { previewShippingRates } from './shipping-rates' ;
2020-04-08 15:03:39 +00:00
2021-10-26 13:03:51 +00:00
/ * *
* Prices from the API may change because of this display setting . This makes the response use either
* wc_get_price_including_tax or wc_get_price_excluding_tax . It is correct that this setting changes the cart preview
* data .
*
* WooCommerce core has 2 settings which control this , one for cart ( displayCartPricesIncludingTax ) , and one for the
* rest of the store ( displayProductPricesIncludingTax ) . Because of this , Cart endpoints use displayCartPricesIncludingTax
* which is the most appropriate .
*
* Handling the display settings server - side helps work around rounding / display issues that can arise from manually
* adding tax to a price .
* /
2021-05-17 14:00:57 +00:00
const displayWithTax = getSetting ( 'displayCartPricesIncludingTax' , false ) ;
2021-10-26 13:03:51 +00:00
2020-02-18 23:06:37 +00:00
// Sample data for cart block.
// This closely resembles the data returned from the Store API /cart endpoint.
2021-08-13 13:28:41 +00:00
// https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/src/StoreApi/docs/cart.md#cart-response
2021-03-10 15:03:26 +00:00
export const previewCart : CartResponse = {
2020-03-13 13:41:59 +00:00
coupons : [ ] ,
2021-04-22 11:37:27 +00:00
shipping_rates : getSetting ( 'shippingMethodsExist' , false )
? previewShippingRates
: [ ] ,
2020-02-18 23:06:37 +00:00
items : [
{
key : '1' ,
id : 1 ,
quantity : 2 ,
2022-12-22 07:23:11 +00:00
catalog_visibility : 'visible' ,
2020-02-18 23:06:37 +00:00
name : __ ( 'Beanie' , 'woo-gutenberg-products-block' ) ,
2022-12-22 07:23:11 +00:00
summary : __ ( 'Beanie' , 'woo-gutenberg-products-block' ) ,
2020-02-18 23:06:37 +00:00
short_description : __ (
'Warm hat for winter' ,
'woo-gutenberg-products-block'
) ,
description :
'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.' ,
sku : 'woo-beanie' ,
permalink : 'https://example.org' ,
low_stock_remaining : 2 ,
2020-03-10 15:14:05 +00:00
backorders_allowed : false ,
2020-07-14 15:25:53 +00:00
show_backorder_badge : false ,
2020-03-10 15:14:05 +00:00
sold_individually : false ,
Add notice on quantity change and update `wc/store/cart` to use thunks (https://github.com/woocommerce/woocommerce-blocks/pull/7938)
* Add receiveCart thunk
* Add mapCartResponseToCart helper
* Add getItemsPendingQuantityUpdate selector
* Update cart resolvers to be thunks
* Remove RECEIVE_CART action and replace with SET_CART_DATA
receiveCart will turn into a thunk.
* Add notifyQuantityChanges functions
* Remove receiveCart from action type definition, replace with setCartData
* Move apiFetchWithHeaders out of controls
This will just be a normal function since we'll be updating actions to thunks which will use this instead of a control.
* Include thunks in actions file
* Update receiveCart action to setCartData
* Update applyCoupon action to a thunk
* Update useStoreCartCoupons to get action from correct place
* Update StoreCartCoupon types
* Add types for Thunk and ThunkReturnType in mapped-types
* Change applyCoupon to a thunk
* Get applyCoupon, removeCoupon, receiveApplyingCoupon from useDispatch
This is to separate the concerns of actions vs. selectors. Previously the actions were fetched during useSelect which is not a pattern we use anywhere else in the codebase. Since we updated the MapToDispatch type, we can now get correctly typed thunks from the data store.
* Improve apiFetchWithHeaders typings
* Convert removeCoupon from generator to thunk
* Add applyCoupon and removeCoupon to CartAction type
* Remove unused old-style type-def
* Add receiveApplyingCoupon & receiveRemovingCoupon to StoreCartCoupon
* Correct issues with StoreCartCoupon type
These were not intended to reflect the actions in data store, rather the functions offered by the useStoreCartCoupons hook.
* Update applyExtensionCartUpdate to a thunk
* Update addItemToCart to thunk
* Add ResolveSelectFromMap type that works with thunks
* Add CartDispatchFromMap and CartResolveSelectFromMap types
We can add this to all data stores to get them working with thunks properly.
* Add docs and update generic name in ResolveSelectFromMap
* Add correct types for thunk resolvers in cart data store
* Update removeItemFromCart to thunk
* Update apiFetchWithHeaders to use generic
* Update selectShippingRate to thunk
* Update resolver tests to test correct thunk functionality
* Update updateCustomerData to thunk
* Update reducer test to reflect new action name
* Update comments on CartDispatchFromMap and CartResolveSelectFromMap
* Add quantity_limits to preview cart
* Make notices speak when shown
* Remove copilot comment
* Add isWithinQuantityLimits function
This is because we shouldn't show a notice if the quantity limits change, but the item's quantity is still OK.
* Add tests for notifyQuantityChanges
* Show notice when multiple_of is updated
* Update test to test for multiple_of changes
* Remove empty export
* Remove controls from cart data store
Not needed anymore since the exported value from the shared-controls file was empty.
* Export a control and async function for apiFetchWithHeaders
This is required because async functions cannot be called from sync generators.
* Use control version of apiFetchWithHeaders in the collections store
* Improve comments and remove incorrect TypeScript
* Update assets/js/data/cart/actions.ts
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Update ResolveSelectFromMap to include selectors too
* Update TS in actions
* Use finally to remove duplicate code
* remove item pending delete/qty update after action runs in all cases
This will also reset the state when the request to remove it/change quantity errors
* Remove unnecessary type from param.
Not needed because we have TS now. The description can stay though, it is useful.
* Update snackbar wording to use active voice
* Remove old WP version check
* Set max quantity to high number instead of null
This would only happen in a niche case, and would require several TS changes to fix, so it's better to set it as a number here. 9999 should be high enough, and is the default quantity limit set below in get_product_quantity_limit
* Set code on woocommerce_rest_cart_invalid_key to 409
This is so the cart is returned in the response, so the client can update.
* Fix typo in comment and add CartSelectFromMap
* Remove unnecessary docblock
* Add getItemsPendingDelete selector
This is needed so we can show a notice for items that are unexpectedly removed from the cart. We need to know which ones are pending delete so we can skip showing the notice for them.
* Add type for notifyQuantityChanges args and change args to object
* Add notifyIfRemoved function
This will check items that have been removed and show a notice for them.
* Fix TS in receiveCart & pass itemsPendingDelete to notifyQuantiyChanges
* Update wording on removal notice
* Update types for notifyQuantityChanges args
* Update tests to reflect new wording and args being an object
* Check item is truth before running comparison of keys
* Update tests for unexpectedly and expectedly removed items
* Ignore print_r to satisfy phpcs
* Update PHP tests to reflect correct response code when deleting items
* Remove unnecessary controls and dispatch events directly from thunk
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-12-16 16:06:37 +00:00
quantity_limits : {
minimum : 1 ,
maximum : 99 ,
multiple_of : 1 ,
editable : true ,
} ,
2020-02-18 23:06:37 +00:00
images : [
{
id : 10 ,
2021-06-29 14:04:24 +00:00
src : WC_BLOCKS_IMAGE_URL + 'previews/beanie.jpg' ,
thumbnail : WC_BLOCKS_IMAGE_URL + 'previews/beanie.jpg' ,
2020-02-18 23:06:37 +00:00
srcset : '' ,
sizes : '' ,
name : '' ,
alt : '' ,
} ,
] ,
variation : [
{
attribute : __ ( 'Color' , 'woo-gutenberg-products-block' ) ,
value : __ ( 'Yellow' , 'woo-gutenberg-products-block' ) ,
} ,
{
attribute : __ ( 'Size' , 'woo-gutenberg-products-block' ) ,
value : __ ( 'Small' , 'woo-gutenberg-products-block' ) ,
} ,
] ,
2020-02-25 12:17:13 +00:00
prices : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
2021-10-26 13:03:51 +00:00
price : displayWithTax ? '12000' : '10000' ,
regular_price : displayWithTax ? '12000' : '10000' ,
sale_price : displayWithTax ? '12000' : '10000' ,
2022-12-22 07:23:11 +00:00
price_range : null ,
2020-03-17 15:34:33 +00:00
raw_prices : {
precision : 6 ,
2021-10-26 13:03:51 +00:00
price : displayWithTax ? '12000000' : '10000000' ,
regular_price : displayWithTax ? '12000000' : '10000000' ,
sale_price : displayWithTax ? '12000000' : '10000000' ,
2020-03-17 15:34:33 +00:00
} ,
2020-02-25 12:17:13 +00:00
} ,
2020-02-18 23:06:37 +00:00
totals : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
2021-10-26 13:03:51 +00:00
line_subtotal : '2000' ,
line_subtotal_tax : '400' ,
line_total : '2000' ,
line_total_tax : '400' ,
2020-02-18 23:06:37 +00:00
} ,
2021-03-16 09:16:56 +00:00
extensions : { } ,
2022-12-22 07:23:11 +00:00
item_data : [ ] ,
2020-02-18 23:06:37 +00:00
} ,
{
key : '2' ,
id : 2 ,
quantity : 1 ,
2022-12-22 07:23:11 +00:00
catalog_visibility : 'visible' ,
2020-02-18 23:06:37 +00:00
name : __ ( 'Cap' , 'woo-gutenberg-products-block' ) ,
2022-12-22 07:23:11 +00:00
summary : __ ( 'Cap' , 'woo-gutenberg-products-block' ) ,
2020-02-18 23:06:37 +00:00
short_description : __ (
'Lightweight baseball cap' ,
'woo-gutenberg-products-block'
) ,
description :
'Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.' ,
sku : 'woo-cap' ,
2022-12-22 07:23:11 +00:00
low_stock_remaining : null ,
2020-02-18 23:06:37 +00:00
permalink : 'https://example.org' ,
2020-03-10 15:14:05 +00:00
backorders_allowed : false ,
2020-07-14 15:25:53 +00:00
show_backorder_badge : false ,
2020-03-10 15:14:05 +00:00
sold_individually : false ,
Add notice on quantity change and update `wc/store/cart` to use thunks (https://github.com/woocommerce/woocommerce-blocks/pull/7938)
* Add receiveCart thunk
* Add mapCartResponseToCart helper
* Add getItemsPendingQuantityUpdate selector
* Update cart resolvers to be thunks
* Remove RECEIVE_CART action and replace with SET_CART_DATA
receiveCart will turn into a thunk.
* Add notifyQuantityChanges functions
* Remove receiveCart from action type definition, replace with setCartData
* Move apiFetchWithHeaders out of controls
This will just be a normal function since we'll be updating actions to thunks which will use this instead of a control.
* Include thunks in actions file
* Update receiveCart action to setCartData
* Update applyCoupon action to a thunk
* Update useStoreCartCoupons to get action from correct place
* Update StoreCartCoupon types
* Add types for Thunk and ThunkReturnType in mapped-types
* Change applyCoupon to a thunk
* Get applyCoupon, removeCoupon, receiveApplyingCoupon from useDispatch
This is to separate the concerns of actions vs. selectors. Previously the actions were fetched during useSelect which is not a pattern we use anywhere else in the codebase. Since we updated the MapToDispatch type, we can now get correctly typed thunks from the data store.
* Improve apiFetchWithHeaders typings
* Convert removeCoupon from generator to thunk
* Add applyCoupon and removeCoupon to CartAction type
* Remove unused old-style type-def
* Add receiveApplyingCoupon & receiveRemovingCoupon to StoreCartCoupon
* Correct issues with StoreCartCoupon type
These were not intended to reflect the actions in data store, rather the functions offered by the useStoreCartCoupons hook.
* Update applyExtensionCartUpdate to a thunk
* Update addItemToCart to thunk
* Add ResolveSelectFromMap type that works with thunks
* Add CartDispatchFromMap and CartResolveSelectFromMap types
We can add this to all data stores to get them working with thunks properly.
* Add docs and update generic name in ResolveSelectFromMap
* Add correct types for thunk resolvers in cart data store
* Update removeItemFromCart to thunk
* Update apiFetchWithHeaders to use generic
* Update selectShippingRate to thunk
* Update resolver tests to test correct thunk functionality
* Update updateCustomerData to thunk
* Update reducer test to reflect new action name
* Update comments on CartDispatchFromMap and CartResolveSelectFromMap
* Add quantity_limits to preview cart
* Make notices speak when shown
* Remove copilot comment
* Add isWithinQuantityLimits function
This is because we shouldn't show a notice if the quantity limits change, but the item's quantity is still OK.
* Add tests for notifyQuantityChanges
* Show notice when multiple_of is updated
* Update test to test for multiple_of changes
* Remove empty export
* Remove controls from cart data store
Not needed anymore since the exported value from the shared-controls file was empty.
* Export a control and async function for apiFetchWithHeaders
This is required because async functions cannot be called from sync generators.
* Use control version of apiFetchWithHeaders in the collections store
* Improve comments and remove incorrect TypeScript
* Update assets/js/data/cart/actions.ts
Co-authored-by: Mike Jolley <mike.jolley@me.com>
* Update ResolveSelectFromMap to include selectors too
* Update TS in actions
* Use finally to remove duplicate code
* remove item pending delete/qty update after action runs in all cases
This will also reset the state when the request to remove it/change quantity errors
* Remove unnecessary type from param.
Not needed because we have TS now. The description can stay though, it is useful.
* Update snackbar wording to use active voice
* Remove old WP version check
* Set max quantity to high number instead of null
This would only happen in a niche case, and would require several TS changes to fix, so it's better to set it as a number here. 9999 should be high enough, and is the default quantity limit set below in get_product_quantity_limit
* Set code on woocommerce_rest_cart_invalid_key to 409
This is so the cart is returned in the response, so the client can update.
* Fix typo in comment and add CartSelectFromMap
* Remove unnecessary docblock
* Add getItemsPendingDelete selector
This is needed so we can show a notice for items that are unexpectedly removed from the cart. We need to know which ones are pending delete so we can skip showing the notice for them.
* Add type for notifyQuantityChanges args and change args to object
* Add notifyIfRemoved function
This will check items that have been removed and show a notice for them.
* Fix TS in receiveCart & pass itemsPendingDelete to notifyQuantiyChanges
* Update wording on removal notice
* Update types for notifyQuantityChanges args
* Update tests to reflect new wording and args being an object
* Check item is truth before running comparison of keys
* Update tests for unexpectedly and expectedly removed items
* Ignore print_r to satisfy phpcs
* Update PHP tests to reflect correct response code when deleting items
* Remove unnecessary controls and dispatch events directly from thunk
Co-authored-by: Mike Jolley <mike.jolley@me.com>
2022-12-16 16:06:37 +00:00
quantity_limits : {
minimum : 1 ,
maximum : 99 ,
multiple_of : 1 ,
editable : true ,
} ,
2020-02-18 23:06:37 +00:00
images : [
{
id : 11 ,
2021-06-29 14:04:24 +00:00
src : WC_BLOCKS_IMAGE_URL + 'previews/cap.jpg' ,
thumbnail : WC_BLOCKS_IMAGE_URL + 'previews/cap.jpg' ,
2020-02-18 23:06:37 +00:00
srcset : '' ,
sizes : '' ,
name : '' ,
alt : '' ,
} ,
] ,
variation : [
{
attribute : __ ( 'Color' , 'woo-gutenberg-products-block' ) ,
value : __ ( 'Orange' , 'woo-gutenberg-products-block' ) ,
} ,
] ,
2020-02-25 12:17:13 +00:00
prices : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
2021-10-26 13:03:51 +00:00
price : displayWithTax ? '2400' : '2000' ,
regular_price : displayWithTax ? '2400' : '2000' ,
sale_price : displayWithTax ? '2400' : '2000' ,
2022-12-22 07:23:11 +00:00
price_range : null ,
2020-03-17 15:34:33 +00:00
raw_prices : {
precision : 6 ,
2021-10-26 13:03:51 +00:00
price : displayWithTax ? '24000000' : '20000000' ,
regular_price : displayWithTax ? '24000000' : '20000000' ,
sale_price : displayWithTax ? '24000000' : '20000000' ,
2020-03-17 15:34:33 +00:00
} ,
2020-02-25 12:17:13 +00:00
} ,
2020-02-18 23:06:37 +00:00
totals : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
2021-10-26 13:03:51 +00:00
line_subtotal : '2000' ,
line_subtotal_tax : '400' ,
line_total : '2000' ,
line_total_tax : '400' ,
2020-02-18 23:06:37 +00:00
} ,
2021-03-16 09:16:56 +00:00
extensions : { } ,
2022-12-22 07:23:11 +00:00
item_data : [ ] ,
2020-02-18 23:06:37 +00:00
} ,
] ,
2022-09-21 06:04:15 +00:00
cross_sells : [
{
id : 1 ,
name : __ ( 'Polo' , 'woo-gutenberg-products-block' ) ,
2022-12-22 07:23:11 +00:00
parent : 0 ,
type : 'simple' ,
variation : '' ,
2022-09-21 06:04:15 +00:00
permalink : 'https://example.org' ,
2022-12-22 07:23:11 +00:00
sku : 'woo-polo' ,
short_description : __ ( 'Polo' , 'woo-gutenberg-products-block' ) ,
description : __ ( 'Polo' , 'woo-gutenberg-products-block' ) ,
on_sale : false ,
2022-09-21 06:04:15 +00:00
prices : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
price : displayWithTax ? '24000' : '20000' ,
regular_price : displayWithTax ? '24000' : '20000' ,
sale_price : displayWithTax ? '12000' : '10000' ,
2022-12-22 07:23:11 +00:00
price_range : null ,
2022-09-21 06:04:15 +00:00
} ,
2022-12-22 07:23:11 +00:00
price_html : '' ,
average_rating : '4.5' ,
review_count : 2 ,
2022-09-21 06:04:15 +00:00
images : [
{
id : 17 ,
src : WC_BLOCKS_IMAGE_URL + 'previews/polo.jpg' ,
thumbnail : WC_BLOCKS_IMAGE_URL + 'previews/polo.jpg' ,
srcset : '' ,
sizes : '' ,
name : '' ,
alt : '' ,
} ,
] ,
2022-12-22 07:23:11 +00:00
categories : [ ] ,
tags : [ ] ,
attributes : [ ] ,
variations : [ ] ,
has_options : false ,
is_purchasable : true ,
is_in_stock : true ,
is_on_backorder : false ,
low_stock_remaining : null ,
sold_individually : false ,
add_to_cart : {
text : '' ,
description : '' ,
url : '' ,
minimum : 1 ,
maximum : 99 ,
multiple_of : 1 ,
} ,
2022-09-21 06:04:15 +00:00
} ,
{
id : 2 ,
name : __ ( 'Long Sleeve Tee' , 'woo-gutenberg-products-block' ) ,
2022-12-22 07:23:11 +00:00
parent : 0 ,
type : 'simple' ,
variation : '' ,
2022-09-21 06:04:15 +00:00
permalink : 'https://example.org' ,
2022-12-22 07:23:11 +00:00
sku : 'woo-long-sleeve-tee' ,
short_description : __ (
'Long Sleeve Tee' ,
'woo-gutenberg-products-block'
) ,
description : __ (
'Long Sleeve Tee' ,
'woo-gutenberg-products-block'
) ,
on_sale : false ,
2022-09-21 06:04:15 +00:00
prices : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
price : displayWithTax ? '30000' : '25000' ,
regular_price : displayWithTax ? '30000' : '25000' ,
sale_price : displayWithTax ? '30000' : '25000' ,
2022-12-22 07:23:11 +00:00
price_range : null ,
2022-09-21 06:04:15 +00:00
} ,
2022-12-22 07:23:11 +00:00
price_html : '' ,
average_rating : '4' ,
review_count : 2 ,
2022-09-21 06:04:15 +00:00
images : [
{
id : 17 ,
src : WC_BLOCKS_IMAGE_URL + 'previews/long-sleeve-tee.jpg' ,
thumbnail :
WC_BLOCKS_IMAGE_URL + 'previews/long-sleeve-tee.jpg' ,
srcset : '' ,
sizes : '' ,
name : '' ,
alt : '' ,
} ,
] ,
2022-12-22 07:23:11 +00:00
categories : [ ] ,
tags : [ ] ,
attributes : [ ] ,
variations : [ ] ,
has_options : false ,
is_purchasable : true ,
is_in_stock : true ,
is_on_backorder : false ,
low_stock_remaining : null ,
sold_individually : false ,
add_to_cart : {
text : '' ,
description : '' ,
url : '' ,
minimum : 1 ,
maximum : 99 ,
multiple_of : 1 ,
} ,
2022-09-21 06:04:15 +00:00
} ,
{
id : 3 ,
name : __ ( 'Hoodie with Zipper' , 'woo-gutenberg-products-block' ) ,
2022-12-22 07:23:11 +00:00
parent : 0 ,
type : 'simple' ,
variation : '' ,
2022-09-21 06:04:15 +00:00
permalink : 'https://example.org' ,
2022-12-22 07:23:11 +00:00
sku : 'woo-hoodie-with-zipper' ,
short_description : __ (
'Hoodie with Zipper' ,
'woo-gutenberg-products-block'
) ,
description : __ (
'Hoodie with Zipper' ,
'woo-gutenberg-products-block'
) ,
2022-09-21 06:04:15 +00:00
on_sale : true ,
prices : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
price : displayWithTax ? '15000' : '12500' ,
regular_price : displayWithTax ? '30000' : '25000' ,
sale_price : displayWithTax ? '15000' : '12500' ,
2022-12-22 07:23:11 +00:00
price_range : null ,
2022-09-21 06:04:15 +00:00
} ,
2022-12-22 07:23:11 +00:00
price_html : '' ,
average_rating : '1' ,
review_count : 2 ,
2022-09-21 06:04:15 +00:00
images : [
{
id : 17 ,
src :
WC_BLOCKS_IMAGE_URL + 'previews/hoodie-with-zipper.jpg' ,
thumbnail :
WC_BLOCKS_IMAGE_URL + 'previews/hoodie-with-zipper.jpg' ,
srcset : '' ,
sizes : '' ,
name : '' ,
alt : '' ,
} ,
] ,
2022-12-22 07:23:11 +00:00
categories : [ ] ,
tags : [ ] ,
attributes : [ ] ,
variations : [ ] ,
has_options : false ,
is_purchasable : true ,
is_in_stock : true ,
is_on_backorder : false ,
low_stock_remaining : null ,
sold_individually : false ,
add_to_cart : {
text : '' ,
description : '' ,
url : '' ,
minimum : 1 ,
maximum : 99 ,
multiple_of : 1 ,
} ,
2022-09-21 06:04:15 +00:00
} ,
{
id : 4 ,
name : __ ( 'Hoodie with Logo' , 'woo-gutenberg-products-block' ) ,
2022-12-22 07:23:11 +00:00
parent : 0 ,
type : 'simple' ,
variation : '' ,
2022-09-21 06:04:15 +00:00
permalink : 'https://example.org' ,
2022-12-22 07:23:11 +00:00
sku : 'woo-hoodie-with-logo' ,
short_description : __ ( 'Polo' , 'woo-gutenberg-products-block' ) ,
description : __ ( 'Polo' , 'woo-gutenberg-products-block' ) ,
2022-09-21 06:04:15 +00:00
on_sale : false ,
prices : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
price : displayWithTax ? '4500' : '4250' ,
regular_price : displayWithTax ? '4500' : '4250' ,
sale_price : displayWithTax ? '4500' : '4250' ,
2022-12-22 07:23:11 +00:00
price_range : null ,
2022-09-21 06:04:15 +00:00
} ,
2022-12-22 07:23:11 +00:00
price_html : '' ,
average_rating : '5' ,
review_count : 2 ,
2022-09-21 06:04:15 +00:00
images : [
{
id : 17 ,
src : WC_BLOCKS_IMAGE_URL + 'previews/hoodie-with-logo.jpg' ,
thumbnail :
WC_BLOCKS_IMAGE_URL + 'previews/hoodie-with-logo.jpg' ,
srcset : '' ,
sizes : '' ,
name : '' ,
alt : '' ,
} ,
] ,
2022-12-22 07:23:11 +00:00
categories : [ ] ,
tags : [ ] ,
attributes : [ ] ,
variations : [ ] ,
has_options : false ,
is_purchasable : true ,
is_in_stock : true ,
is_on_backorder : false ,
low_stock_remaining : null ,
sold_individually : false ,
add_to_cart : {
text : '' ,
description : '' ,
url : '' ,
minimum : 1 ,
maximum : 99 ,
multiple_of : 1 ,
} ,
2022-09-21 06:04:15 +00:00
} ,
{
id : 5 ,
name : __ ( 'Hoodie with Pocket' , 'woo-gutenberg-products-block' ) ,
2022-12-22 07:23:11 +00:00
parent : 0 ,
type : 'simple' ,
variation : '' ,
2022-09-21 06:04:15 +00:00
permalink : 'https://example.org' ,
2022-12-22 07:23:11 +00:00
sku : 'woo-hoodie-with-pocket' ,
short_description : __ (
'Hoodie with Pocket' ,
'woo-gutenberg-products-block'
) ,
description : __ (
'Hoodie with Pocket' ,
'woo-gutenberg-products-block'
) ,
2022-09-21 06:04:15 +00:00
on_sale : true ,
prices : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
price : displayWithTax ? '3500' : '3250' ,
regular_price : displayWithTax ? '4500' : '4250' ,
sale_price : displayWithTax ? '3500' : '3250' ,
2022-12-22 07:23:11 +00:00
price_range : null ,
2022-09-21 06:04:15 +00:00
} ,
2022-12-22 07:23:11 +00:00
price_html : '' ,
average_rating : '3.75' ,
review_count : 4 ,
2022-09-21 06:04:15 +00:00
images : [
{
id : 17 ,
src :
WC_BLOCKS_IMAGE_URL + 'previews/hoodie-with-pocket.jpg' ,
thumbnail :
WC_BLOCKS_IMAGE_URL + 'previews/hoodie-with-pocket.jpg' ,
srcset : '' ,
sizes : '' ,
name : '' ,
alt : '' ,
} ,
] ,
2022-12-22 07:23:11 +00:00
categories : [ ] ,
tags : [ ] ,
attributes : [ ] ,
variations : [ ] ,
has_options : false ,
is_purchasable : true ,
is_in_stock : true ,
is_on_backorder : false ,
low_stock_remaining : null ,
sold_individually : false ,
add_to_cart : {
text : '' ,
description : '' ,
url : '' ,
minimum : 1 ,
maximum : 99 ,
multiple_of : 1 ,
} ,
2022-09-21 06:04:15 +00:00
} ,
{
id : 6 ,
name : __ ( 'T-Shirt' , 'woo-gutenberg-products-block' ) ,
2022-12-22 07:23:11 +00:00
parent : 0 ,
type : 'simple' ,
variation : '' ,
2022-09-21 06:04:15 +00:00
permalink : 'https://example.org' ,
2022-12-22 07:23:11 +00:00
sku : 'woo-t-shirt' ,
short_description : __ ( 'T-Shirt' , 'woo-gutenberg-products-block' ) ,
description : __ ( 'T-Shirt' , 'woo-gutenberg-products-block' ) ,
2022-09-21 06:04:15 +00:00
on_sale : false ,
prices : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
price : displayWithTax ? '1800' : '1500' ,
regular_price : displayWithTax ? '1800' : '1500' ,
sale_price : displayWithTax ? '1800' : '1500' ,
2022-12-22 07:23:11 +00:00
price_range : null ,
2022-09-21 06:04:15 +00:00
} ,
2022-12-22 07:23:11 +00:00
price_html : '' ,
average_rating : '3' ,
review_count : 2 ,
2022-09-21 06:04:15 +00:00
images : [
{
id : 17 ,
src : WC_BLOCKS_IMAGE_URL + 'previews/tshirt.jpg' ,
thumbnail : WC_BLOCKS_IMAGE_URL + 'previews/tshirt.jpg' ,
srcset : '' ,
sizes : '' ,
name : '' ,
alt : '' ,
} ,
] ,
2022-12-22 07:23:11 +00:00
categories : [ ] ,
tags : [ ] ,
attributes : [ ] ,
variations : [ ] ,
has_options : false ,
is_purchasable : true ,
is_in_stock : true ,
is_on_backorder : false ,
low_stock_remaining : null ,
sold_individually : false ,
add_to_cart : {
text : '' ,
description : '' ,
url : '' ,
minimum : 1 ,
maximum : 99 ,
multiple_of : 1 ,
} ,
2022-09-21 06:04:15 +00:00
} ,
] ,
2022-04-01 13:45:18 +00:00
fees : [
{
id : 'fee' ,
name : __ ( 'Fee' , 'woo-gutenberg-products-block' ) ,
totals : {
currency_code : 'USD' ,
currency_symbol : '$' ,
currency_minor_unit : 2 ,
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
total : '100' ,
total_tax : '20' ,
} ,
} ,
] ,
2020-03-17 12:11:30 +00:00
items_count : 3 ,
2020-03-13 13:41:59 +00:00
items_weight : 0 ,
2020-04-09 14:01:11 +00:00
needs_payment : true ,
2021-04-22 11:37:27 +00:00
needs_shipping : getSetting ( 'shippingEnabled' , true ) ,
has_calculated_shipping : true ,
2021-03-10 15:03:26 +00:00
shipping_address : {
first_name : '' ,
last_name : '' ,
company : '' ,
address_1 : '' ,
address_2 : '' ,
city : '' ,
state : '' ,
postcode : '' ,
country : '' ,
2021-07-22 11:03:00 +00:00
phone : '' ,
2021-03-10 15:03:26 +00:00
} ,
billing_address : {
first_name : '' ,
last_name : '' ,
company : '' ,
address_1 : '' ,
address_2 : '' ,
city : '' ,
state : '' ,
postcode : '' ,
country : '' ,
email : '' ,
phone : '' ,
} ,
2020-02-18 23:06:37 +00:00
totals : {
2020-03-13 13:41:59 +00:00
currency_code : 'USD' ,
currency_symbol : '$' ,
2020-02-18 23:06:37 +00:00
currency_minor_unit : 2 ,
2020-03-13 13:41:59 +00:00
currency_decimal_separator : '.' ,
currency_thousand_separator : ',' ,
currency_prefix : '$' ,
currency_suffix : '' ,
2021-10-26 13:03:51 +00:00
total_items : '4000' ,
total_items_tax : '800' ,
2022-04-01 13:45:18 +00:00
total_fees : '100' ,
total_fees_tax : '20' ,
2020-02-18 23:06:37 +00:00
total_discount : '0' ,
total_discount_tax : '0' ,
2020-11-17 11:58:38 +00:00
total_shipping : '0' ,
2020-02-18 23:06:37 +00:00
total_shipping_tax : '0' ,
2022-04-01 13:45:18 +00:00
total_tax : '820' ,
total_price : '4920' ,
2021-05-17 14:00:57 +00:00
tax_lines : [
{
name : __ ( 'Sales tax' , 'woo-gutenberg-products-block' ) ,
rate : '20%' ,
2022-04-01 13:45:18 +00:00
price : '820' ,
2021-05-17 14:00:57 +00:00
} ,
] ,
2020-02-18 23:06:37 +00:00
} ,
2021-08-13 13:28:41 +00:00
errors : [ ] ,
payment_requirements : [ 'products' ] ,
extensions : { } ,
2020-02-18 23:06:37 +00:00
} ;