2020-06-05 16:49:07 +00:00
/ * *
* The default fixtures data is shaped according to WC REST API
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs|WooCommerce REST API}
* /
2021-12-23 16:26:10 +00:00
/ * *
* Product attributes fixture data , using the create attribute and batch create terms .
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#create-a-product-attribute|Create a product attribute}
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-attribute-terms|Batch update attribute terms}
* /
const Attributes = ( ) => [
{
attribute : { name : 'Capacity' } ,
terms : [
{
name : '32gb' ,
} ,
{
name : '64gb' ,
} ,
{
name : '128gb' ,
} ,
] ,
} ,
{
attribute : { name : 'Shade' } ,
terms : [
{
name : 'Red' ,
} ,
{
name : 'Blue' ,
} ,
{
name : 'Black' ,
} ,
] ,
} ,
] ;
2020-06-05 16:49:07 +00:00
/ * *
* Coupons fixture data , using the create batch endpoint
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-coupons|Batch update coupons}
* /
const Coupons = ( ) => [
{
code : 'coupon' ,
discount _type : 'fixed_cart' ,
amount : '5' ,
} ,
{
code : 'oldcoupon' ,
discount _type : 'fixed_cart' ,
amount : '5' ,
date _expires : '2020-01-01' ,
} ,
{
code : 'below100' ,
discount _type : 'percent' ,
amount : '20' ,
maximum _amount : '100.00' ,
} ,
{
code : 'above50' ,
discount _type : 'percent' ,
amount : '20' ,
minimum _amount : '50.00' ,
} ,
{
code : 'a12s' ,
discount _type : 'percent' ,
amount : '100' ,
individual _use : true ,
email _restrictions : '*@automattic.com%2C *@a8c.com' ,
} ,
{
code : 'freeshipping' ,
discount _type : 'percent' ,
amount : '0' ,
free _shipping : true ,
} ,
] ;
/ * *
* Reviews fixture data , using the create batch endpoint
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-product-reviews|Batch update product reviews}
* @ param { number } id Product ID to add reviews to .
* /
const ReviewsInProduct = ( id ) => [
{
product _id : id ,
review : 'Looks fine' ,
reviewer : 'John Doe' ,
reviewer _email : 'john.doe@example.com' ,
rating : 4 ,
} ,
{
product _id : id ,
review : 'I love this album' ,
reviewer : 'John Doe' ,
reviewer _email : 'john.doe@example.com' ,
rating : 5 ,
} ,
{
product _id : id ,
review : 'a fine review' ,
reviewer : "John Doe' niece" ,
reviewer _email : 'john.doe@example.com' ,
rating : 5 ,
} ,
] ;
2020-07-06 18:48:39 +00:00
/ * *
* Product category fixture data , using the create batch endpoint
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-product-categories|Batch update product categories}
* /
const Categories = ( ) => [
{
name : 'Music' ,
} ,
] ;
2022-02-21 12:26:22 +00:00
/ * *
* Product tags fixture data , using the create batch endpoint
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-product-tags|Batch update product tags}
* /
const Tags = ( ) => [
{
name : 'Newest' ,
} ,
] ;
2020-06-05 16:49:07 +00:00
/ * *
* Product fixture data , using the create batch endpoint
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-products|Batch update products}
* /
const Products = ( ) => [
{
name : 'Woo Single #1' ,
type : 'simple' ,
regular _price : '21.99' ,
virtual : true ,
downloadable : true ,
downloads : [
{
name : 'Woo Single' ,
2022-06-15 09:56:52 +00:00
file : 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' ,
2020-06-05 16:49:07 +00:00
} ,
] ,
images : [
{
2022-06-15 09:56:52 +00:00
src : 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' ,
2020-06-05 16:49:07 +00:00
} ,
] ,
2020-07-06 18:48:39 +00:00
categories : [ 'Music' ] ,
} ,
2021-12-23 16:26:10 +00:00
{
name : '128GB USB Stick' ,
type : 'simple' ,
regular _price : '2.99' ,
virtual : false ,
downloadable : false ,
images : [
{
2022-06-15 09:56:52 +00:00
src : 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' ,
2021-12-23 16:26:10 +00:00
} ,
] ,
attributes : [
{
name : 'Capacity' ,
position : 0 ,
visible : true ,
options : [ '128gb' ] ,
} ,
] ,
2022-02-21 12:26:22 +00:00
tags : [ 'Newest' ] ,
2021-12-23 16:26:10 +00:00
} ,
{
name : '32GB USB Stick' ,
type : 'simple' ,
regular _price : '1.99' ,
virtual : false ,
downloadable : false ,
images : [
{
2022-06-15 09:56:52 +00:00
src : 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' ,
2021-12-23 16:26:10 +00:00
} ,
] ,
attributes : [
{
name : 'Capacity' ,
position : 0 ,
visible : true ,
options : [ '32gb' ] ,
} ,
] ,
} ,
2020-07-06 18:48:39 +00:00
{
name : 'Woo Single #2' ,
type : 'simple' ,
regular _price : '25.99' ,
virtual : true ,
downloadable : true ,
downloads : [
{
name : 'Woo Single 2' ,
2022-06-15 09:56:52 +00:00
file : 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' ,
2020-07-06 18:48:39 +00:00
} ,
] ,
images : [
{
2022-06-15 09:56:52 +00:00
src : 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' ,
2020-07-06 18:48:39 +00:00
} ,
] ,
categories : [ 'Music' ] ,
2022-02-21 12:26:22 +00:00
tags : [ 'Newest' ] ,
2020-06-05 16:49:07 +00:00
} ,
2022-05-13 09:11:02 +00:00
{
name : 'Woo Single #3 - Limited Edition' ,
type : 'simple' ,
regular _price : '100.00' ,
2022-10-14 03:25:02 +00:00
sale _price : '90.00' ,
2022-05-13 09:11:02 +00:00
virtual : true ,
downloadable : true ,
downloads : [
{
name : 'Woo Single 2' ,
2022-06-15 09:56:52 +00:00
file : 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' ,
2022-05-13 09:11:02 +00:00
} ,
] ,
images : [
{
2022-06-15 09:56:52 +00:00
src : 'http://demo.woothemes.com/woocommerce/wp-content/uploads/sites/56/2013/06/cd_4_angle.jpg' ,
2022-05-13 09:11:02 +00:00
} ,
] ,
categories : [ 'Music' ] ,
stock _status : 'outofstock' ,
tags : [ 'Newest' ] ,
} ,
2020-06-05 16:49:07 +00:00
] ;
/ * *
* Settings fixture data , using the update batch endpoint .
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-setting-options|Batch update setting options}
* /
const Settings = ( ) => [
{
id : 'woocommerce_store_address' ,
value : '60 29th Street #343' ,
} ,
{
id : 'woocommerce_store_city' ,
value : 'San Francisco' ,
} ,
{
id : 'woocommerce_store_country' ,
value : 'US:CA' ,
} ,
{
id : 'woocommerce_store_postcode' ,
value : '94110' ,
} ,
{
id : 'woocommerce_allowed_countries' ,
value : 'specific' ,
} ,
{
id : 'woocommerce_specific_allowed_countries' ,
value : [ 'DZ' , 'CA' , 'NZ' , 'ES' , 'GB' , 'US' ] ,
} ,
{
id : 'woocommerce_ship_to_countries' ,
value : 'specific' ,
} ,
{
id : 'woocommerce_specific_ship_to_countries' ,
value : [ 'DZ' , 'CA' , 'NZ' , 'ES' , 'GB' , 'US' ] ,
} ,
{
id : 'woocommerce_enable_coupons' ,
value : 'yes' ,
} ,
{
id : 'woocommerce_calc_taxes' ,
value : 'yes' ,
} ,
{
id : 'woocommerce_currency' ,
value : 'USD' ,
} ,
] ;
2020-07-29 13:39:15 +00:00
/ * *
* Page settings fixture data , using the update batch endpoint .
*
2020-09-20 23:54:08 +00:00
* @ param { Array } pages
*
2020-07-29 13:39:15 +00:00
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-setting-options|Batch update setting options}
* /
const PageSettings = ( pages = [ ] ) => {
2022-10-10 10:42:59 +00:00
const cart = pages . find ( ( page ) => page . slug === 'cart-block' ) ;
const checkout = pages . find ( ( page ) => page . slug === 'checkout-block' ) ;
2020-07-29 13:39:15 +00:00
return [
{
id : 'woocommerce_cart_page_id' ,
2022-10-10 10:42:59 +00:00
value : cart ? . id . toString ( ) || '' ,
2020-07-29 13:39:15 +00:00
} ,
{
id : 'woocommerce_checkout_page_id' ,
2022-10-10 10:42:59 +00:00
value : checkout ? . id . toString ( ) || '' ,
2020-07-29 13:39:15 +00:00
} ,
] ;
} ;
2020-06-05 16:49:07 +00:00
/ * *
* Shipping Zones fixture data , using the shipping zone endpoint , shipping
* location , and shipping method endpoint .
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#create-a-shipping-zone|Create a shipping zone}
2022-02-14 10:55:28 +00:00
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#update-a-locations-of-a-shipping-zone|Update a locations of a shipping zone}
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#include-a-shipping-method-to-a-shipping-zone|Include a shipping method to a shipping zone}
2020-06-05 16:49:07 +00:00
* /
const Shipping = ( ) => [
{
name : 'UK' ,
locations : [
{
code : 'UK' ,
} ,
] ,
methods : [
{
method _id : 'flat_rate' ,
settings : {
title : 'Normal Shipping' ,
cost : '20.00' ,
} ,
} ,
{
method _id : 'free_shipping' ,
settings : {
title : 'Free Shipping' ,
cost : '00.00' ,
requires : 'coupon' ,
} ,
} ,
] ,
} ,
2022-03-09 12:23:52 +00:00
{
name : 'US' ,
locations : [
{
code : 'US' ,
} ,
] ,
methods : [
{
method _id : 'flat_rate' ,
settings : {
title : 'Normal Shipping' ,
cost : '20.00' ,
} ,
} ,
{
method _id : 'free_shipping' ,
settings : {
title : 'Free Shipping' ,
cost : '00.00' ,
} ,
} ,
] ,
} ,
2020-06-05 16:49:07 +00:00
] ;
/ * *
* Taxes rates fixture data , using the create batch endpoint .
*
* @ see { @ link https : //woocommerce.github.io/woocommerce-rest-api-docs/#batch-update-tax-rates|Batch update tax rates}
* /
const Taxes = ( ) => [
{
country : 'US' ,
rate : '5.0000' ,
name : 'State Tax' ,
shipping : false ,
priority : 1 ,
} ,
{
country : 'US' ,
rate : '10.000' ,
name : 'Sale Tax' ,
shipping : false ,
priority : 2 ,
} ,
{
country : 'UK' ,
rate : '20.000' ,
name : 'VAT' ,
shipping : false ,
} ,
] ;
module . exports = {
2021-12-23 16:26:10 +00:00
Attributes ,
2020-06-05 16:49:07 +00:00
Coupons ,
ReviewsInProduct ,
2020-07-06 18:48:39 +00:00
Categories ,
2020-06-05 16:49:07 +00:00
Products ,
Settings ,
2020-07-29 13:39:15 +00:00
PageSettings ,
2020-06-05 16:49:07 +00:00
Shipping ,
2022-02-21 12:26:22 +00:00
Tags ,
2020-06-05 16:49:07 +00:00
Taxes ,
} ;