2020-02-18 23:06:37 +00:00
/ * *
* External dependencies
* /
import { __ } from '@wordpress/i18n' ;
2020-04-08 15:03:39 +00:00
import {
2021-03-16 09:57:04 +00:00
SHIPPING_COST_REQUIRES_ADDRESS ,
2020-04-08 15:03:39 +00:00
SHIPPING_METHODS_EXIST ,
WC_BLOCKS_ASSET_URL ,
2020-04-14 06:01:59 +00:00
SHIPPING_ENABLED ,
2020-04-08 15:03:39 +00:00
} from '@woocommerce/block-settings' ;
2021-03-10 15:03:26 +00:00
import { CartResponse } from '@woocommerce/types' ;
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
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.
2020-09-26 17:28:16 +00:00
// https://github.com/woocommerce/woocommerce-gutenberg-products-block/tree/trunk/src/RestApi/StoreApi#cart-api
2021-03-10 15:03:26 +00:00
export const previewCart : CartResponse = {
2020-03-13 13:41:59 +00:00
coupons : [ ] ,
2020-04-07 15:41:22 +00:00
shipping_rates : SHIPPING_METHODS_EXIST ? previewShippingRates : [ ] ,
2020-02-18 23:06:37 +00:00
items : [
{
key : '1' ,
id : 1 ,
quantity : 2 ,
name : __ ( 'Beanie' , 'woo-gutenberg-products-block' ) ,
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 ,
2020-02-18 23:06:37 +00:00
images : [
{
id : 10 ,
2020-04-08 15:03:39 +00:00
src : WC_BLOCKS_ASSET_URL + 'img/beanie.jpg' ,
thumbnail : WC_BLOCKS_ASSET_URL + 'img/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 : '' ,
price : '800' ,
regular_price : '800' ,
sale_price : '800' ,
2020-03-17 15:34:33 +00:00
raw_prices : {
precision : 6 ,
price : '8000000' ,
regular_price : '8000000' ,
sale_price : '8000000' ,
} ,
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 : '' ,
2020-02-25 12:17:13 +00:00
line_subtotal : '1600' ,
2020-02-18 23:06:37 +00:00
line_subtotal_tax : '0' ,
2020-02-25 12:17:13 +00:00
line_total : '1600' ,
2020-02-18 23:06:37 +00:00
line_total_tax : '0' ,
} ,
2021-03-16 09:16:56 +00:00
extensions : { } ,
2020-02-18 23:06:37 +00:00
} ,
{
key : '2' ,
id : 2 ,
quantity : 1 ,
name : __ ( 'Cap' , 'woo-gutenberg-products-block' ) ,
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' ,
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 ,
2020-02-18 23:06:37 +00:00
images : [
{
id : 11 ,
2020-04-08 15:03:39 +00:00
src : WC_BLOCKS_ASSET_URL + 'img/cap.jpg' ,
thumbnail : WC_BLOCKS_ASSET_URL + 'img/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 : '' ,
price : '1400' ,
regular_price : '1600' ,
sale_price : '1400' ,
2020-03-17 15:34:33 +00:00
raw_prices : {
precision : 6 ,
price : '14000000' ,
regular_price : '16000000' ,
sale_price : '14000000' ,
} ,
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 : '' ,
2020-02-25 12:17:13 +00:00
line_subtotal : '1400' ,
2020-02-18 23:06:37 +00:00
line_subtotal_tax : '0' ,
line_total : '1400' ,
line_total_tax : '0' ,
} ,
2021-03-16 09:16:56 +00:00
extensions : { } ,
2020-02-18 23:06:37 +00:00
} ,
] ,
2021-01-13 16:57:42 +00:00
fees : [ ] ,
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 ,
2020-04-14 06:01:59 +00:00
needs_shipping : SHIPPING_ENABLED ,
2021-03-16 09:57:04 +00:00
has_calculated_shipping : ! SHIPPING_COST_REQUIRES_ADDRESS ,
2021-03-16 09:16:56 +00:00
extensions : { } ,
2021-03-10 15:03:26 +00:00
shipping_address : {
first_name : '' ,
last_name : '' ,
company : '' ,
address_1 : '' ,
address_2 : '' ,
city : '' ,
state : '' ,
postcode : '' ,
country : '' ,
} ,
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 : '' ,
2020-02-25 12:17:13 +00:00
total_items : '3000' ,
2020-02-18 23:06:37 +00:00
total_items_tax : '0' ,
total_fees : '0' ,
total_fees_tax : '0' ,
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' ,
total_tax : '0' ,
2020-11-17 11:58:38 +00:00
total_price : '3000' ,
2020-03-13 13:41:59 +00:00
tax_lines : [ ] ,
2020-02-18 23:06:37 +00:00
} ,
} ;