first commit
This commit is contained in:
@@ -0,0 +1,258 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings';
|
||||
import { CartResponse } from '@woocommerce/types';
|
||||
import { getSetting } from '@woocommerce/settings';
|
||||
|
||||
/**
|
||||
* Internal dependencies
|
||||
*/
|
||||
import { previewShippingRates } from './shipping-rates';
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
const displayWithTax = getSetting( 'displayCartPricesIncludingTax', false );
|
||||
|
||||
// Sample data for cart block.
|
||||
// This closely resembles the data returned from the Store API /cart endpoint.
|
||||
// https://github.com/woocommerce/woocommerce-gutenberg-products-block/blob/trunk/src/StoreApi/docs/cart.md#cart-response
|
||||
export const previewCart: CartResponse = {
|
||||
coupons: [],
|
||||
shipping_rates: getSetting( 'shippingMethodsExist', false )
|
||||
? previewShippingRates
|
||||
: [],
|
||||
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,
|
||||
backorders_allowed: false,
|
||||
show_backorder_badge: false,
|
||||
sold_individually: false,
|
||||
images: [
|
||||
{
|
||||
id: 10,
|
||||
src: WC_BLOCKS_IMAGE_URL + 'previews/beanie.jpg',
|
||||
thumbnail: WC_BLOCKS_IMAGE_URL + 'previews/beanie.jpg',
|
||||
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' ),
|
||||
},
|
||||
],
|
||||
prices: {
|
||||
currency_code: 'USD',
|
||||
currency_symbol: '$',
|
||||
currency_minor_unit: 2,
|
||||
currency_decimal_separator: '.',
|
||||
currency_thousand_separator: ',',
|
||||
currency_prefix: '$',
|
||||
currency_suffix: '',
|
||||
price: displayWithTax ? '12000' : '10000',
|
||||
regular_price: displayWithTax ? '12000' : '10000',
|
||||
sale_price: displayWithTax ? '12000' : '10000',
|
||||
raw_prices: {
|
||||
precision: 6,
|
||||
price: displayWithTax ? '12000000' : '10000000',
|
||||
regular_price: displayWithTax ? '12000000' : '10000000',
|
||||
sale_price: displayWithTax ? '12000000' : '10000000',
|
||||
},
|
||||
},
|
||||
totals: {
|
||||
currency_code: 'USD',
|
||||
currency_symbol: '$',
|
||||
currency_minor_unit: 2,
|
||||
currency_decimal_separator: '.',
|
||||
currency_thousand_separator: ',',
|
||||
currency_prefix: '$',
|
||||
currency_suffix: '',
|
||||
line_subtotal: '2000',
|
||||
line_subtotal_tax: '400',
|
||||
line_total: '2000',
|
||||
line_total_tax: '400',
|
||||
},
|
||||
extensions: {},
|
||||
},
|
||||
{
|
||||
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',
|
||||
backorders_allowed: false,
|
||||
show_backorder_badge: false,
|
||||
sold_individually: false,
|
||||
images: [
|
||||
{
|
||||
id: 11,
|
||||
src: WC_BLOCKS_IMAGE_URL + 'previews/cap.jpg',
|
||||
thumbnail: WC_BLOCKS_IMAGE_URL + 'previews/cap.jpg',
|
||||
srcset: '',
|
||||
sizes: '',
|
||||
name: '',
|
||||
alt: '',
|
||||
},
|
||||
],
|
||||
variation: [
|
||||
{
|
||||
attribute: __( 'Color', 'woo-gutenberg-products-block' ),
|
||||
value: __( 'Orange', 'woo-gutenberg-products-block' ),
|
||||
},
|
||||
],
|
||||
prices: {
|
||||
currency_code: 'USD',
|
||||
currency_symbol: '$',
|
||||
currency_minor_unit: 2,
|
||||
currency_decimal_separator: '.',
|
||||
currency_thousand_separator: ',',
|
||||
currency_prefix: '$',
|
||||
currency_suffix: '',
|
||||
price: displayWithTax ? '2400' : '2000',
|
||||
regular_price: displayWithTax ? '2400' : '2000',
|
||||
sale_price: displayWithTax ? '2400' : '2000',
|
||||
raw_prices: {
|
||||
precision: 6,
|
||||
price: displayWithTax ? '24000000' : '20000000',
|
||||
regular_price: displayWithTax ? '24000000' : '20000000',
|
||||
sale_price: displayWithTax ? '24000000' : '20000000',
|
||||
},
|
||||
},
|
||||
totals: {
|
||||
currency_code: 'USD',
|
||||
currency_symbol: '$',
|
||||
currency_minor_unit: 2,
|
||||
currency_decimal_separator: '.',
|
||||
currency_thousand_separator: ',',
|
||||
currency_prefix: '$',
|
||||
currency_suffix: '',
|
||||
line_subtotal: '2000',
|
||||
line_subtotal_tax: '400',
|
||||
line_total: '2000',
|
||||
line_total_tax: '400',
|
||||
},
|
||||
extensions: {},
|
||||
},
|
||||
],
|
||||
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',
|
||||
tax_lines: [
|
||||
{
|
||||
name: __( 'Sales tax', 'woo-gutenberg-products-block' ),
|
||||
rate: '20%',
|
||||
price: '20',
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
],
|
||||
items_count: 3,
|
||||
items_weight: 0,
|
||||
needs_payment: true,
|
||||
needs_shipping: getSetting( 'shippingEnabled', true ),
|
||||
has_calculated_shipping: true,
|
||||
shipping_address: {
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
company: '',
|
||||
address_1: '',
|
||||
address_2: '',
|
||||
city: '',
|
||||
state: '',
|
||||
postcode: '',
|
||||
country: '',
|
||||
phone: '',
|
||||
},
|
||||
billing_address: {
|
||||
first_name: '',
|
||||
last_name: '',
|
||||
company: '',
|
||||
address_1: '',
|
||||
address_2: '',
|
||||
city: '',
|
||||
state: '',
|
||||
postcode: '',
|
||||
country: '',
|
||||
email: '',
|
||||
phone: '',
|
||||
},
|
||||
totals: {
|
||||
currency_code: 'USD',
|
||||
currency_symbol: '$',
|
||||
currency_minor_unit: 2,
|
||||
currency_decimal_separator: '.',
|
||||
currency_thousand_separator: ',',
|
||||
currency_prefix: '$',
|
||||
currency_suffix: '',
|
||||
total_items: '4000',
|
||||
total_items_tax: '800',
|
||||
total_fees: '100',
|
||||
total_fees_tax: '20',
|
||||
total_discount: '0',
|
||||
total_discount_tax: '0',
|
||||
total_shipping: '0',
|
||||
total_shipping_tax: '0',
|
||||
total_tax: '820',
|
||||
total_price: '4920',
|
||||
tax_lines: [
|
||||
{
|
||||
name: __( 'Sales tax', 'woo-gutenberg-products-block' ),
|
||||
rate: '20%',
|
||||
price: '820',
|
||||
},
|
||||
],
|
||||
},
|
||||
errors: [],
|
||||
payment_requirements: [ 'products' ],
|
||||
extensions: {},
|
||||
};
|
||||
@@ -0,0 +1,30 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings';
|
||||
|
||||
export const previewCategories = [
|
||||
{
|
||||
id: 1,
|
||||
name: __( 'Clothing', 'woocommerce' ),
|
||||
slug: 'clothing',
|
||||
parent: 0,
|
||||
count: 10,
|
||||
description: `<p>${ __(
|
||||
'Branded t-shirts, jumpers, pants and more!',
|
||||
'woocommerce'
|
||||
) }</p>\n`,
|
||||
image: {
|
||||
id: 1,
|
||||
date_created: '2019-07-15T17:05:04',
|
||||
date_created_gmt: '2019-07-15T17:05:04',
|
||||
date_modified: '2019-07-15T17:05:04',
|
||||
date_modified_gmt: '2019-07-15T17:05:04',
|
||||
src: WC_BLOCKS_IMAGE_URL + 'previews/collection.jpg',
|
||||
name: '',
|
||||
alt: '',
|
||||
},
|
||||
permalink: '#',
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,399 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
export const gridBlockPreview = (
|
||||
<svg
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
fill="none"
|
||||
viewBox="0 0 230 250"
|
||||
style={ {
|
||||
width: '100%',
|
||||
} }
|
||||
>
|
||||
<title>Grid Block Preview</title>
|
||||
<rect
|
||||
width="65.374"
|
||||
height="65.374"
|
||||
x=".162"
|
||||
y=".779"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="47.266"
|
||||
height="5.148"
|
||||
x="9.216"
|
||||
y="76.153"
|
||||
fill="#E1E3E6"
|
||||
rx="2.574"
|
||||
/>
|
||||
<rect
|
||||
width="62.8"
|
||||
height="15"
|
||||
x="1.565"
|
||||
y="101.448"
|
||||
fill="#E1E3E6"
|
||||
rx="5"
|
||||
/>
|
||||
<rect
|
||||
width="65.374"
|
||||
height="65.374"
|
||||
x=".162"
|
||||
y="136.277"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="47.266"
|
||||
height="5.148"
|
||||
x="9.216"
|
||||
y="211.651"
|
||||
fill="#E1E3E6"
|
||||
rx="2.574"
|
||||
/>
|
||||
<rect
|
||||
width="62.8"
|
||||
height="15"
|
||||
x="1.565"
|
||||
y="236.946"
|
||||
fill="#E1E3E6"
|
||||
rx="5"
|
||||
/>
|
||||
<rect
|
||||
width="65.374"
|
||||
height="65.374"
|
||||
x="82.478"
|
||||
y=".779"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="47.266"
|
||||
height="5.148"
|
||||
x="91.532"
|
||||
y="76.153"
|
||||
fill="#E1E3E6"
|
||||
rx="2.574"
|
||||
/>
|
||||
<rect
|
||||
width="62.8"
|
||||
height="15"
|
||||
x="83.882"
|
||||
y="101.448"
|
||||
fill="#E1E3E6"
|
||||
rx="5"
|
||||
/>
|
||||
<rect
|
||||
width="65.374"
|
||||
height="65.374"
|
||||
x="82.478"
|
||||
y="136.277"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="47.266"
|
||||
height="5.148"
|
||||
x="91.532"
|
||||
y="211.651"
|
||||
fill="#E1E3E6"
|
||||
rx="2.574"
|
||||
/>
|
||||
<rect
|
||||
width="62.8"
|
||||
height="15"
|
||||
x="83.882"
|
||||
y="236.946"
|
||||
fill="#E1E3E6"
|
||||
rx="5"
|
||||
/>
|
||||
<rect
|
||||
width="65.374"
|
||||
height="65.374"
|
||||
x="164.788"
|
||||
y=".779"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="47.266"
|
||||
height="5.148"
|
||||
x="173.843"
|
||||
y="76.153"
|
||||
fill="#E1E3E6"
|
||||
rx="2.574"
|
||||
/>
|
||||
<rect
|
||||
width="62.8"
|
||||
height="15"
|
||||
x="166.192"
|
||||
y="101.448"
|
||||
fill="#E1E3E6"
|
||||
rx="5"
|
||||
/>
|
||||
<rect
|
||||
width="65.374"
|
||||
height="65.374"
|
||||
x="164.788"
|
||||
y="136.277"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="47.266"
|
||||
height="5.148"
|
||||
x="173.843"
|
||||
y="211.651"
|
||||
fill="#E1E3E6"
|
||||
rx="2.574"
|
||||
/>
|
||||
<rect
|
||||
width="62.8"
|
||||
height="15"
|
||||
x="166.192"
|
||||
y="236.946"
|
||||
fill="#E1E3E6"
|
||||
rx="5"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="13.283"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="21.498"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="29.713"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="37.927"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="46.238"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="95.599"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="103.814"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="112.029"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="120.243"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="128.554"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="177.909"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="186.124"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="194.339"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="202.553"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="210.864"
|
||||
y="86.301"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="13.283"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="21.498"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="29.713"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="37.927"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="46.238"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="95.599"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="103.814"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="112.029"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="120.243"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="128.554"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="177.909"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="186.124"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="194.339"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="202.553"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
<rect
|
||||
width="6.177"
|
||||
height="6.177"
|
||||
x="210.864"
|
||||
y="221.798"
|
||||
fill="#E1E3E6"
|
||||
rx="3"
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
@@ -0,0 +1,9 @@
|
||||
export { previewProducts } from './products';
|
||||
export { previewCart } from './cart';
|
||||
export { previewReviews } from './reviews';
|
||||
export { previewCategories } from './categories';
|
||||
export { previewShippingRates } from './shipping-rates';
|
||||
export { previewSavedPaymentMethods } from './saved-payment-methods';
|
||||
|
||||
export { gridBlockPreview } from './grid-block';
|
||||
export { singleProductBlockPreview } from './single-product-block';
|
||||
@@ -0,0 +1,67 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { WC_BLOCKS_IMAGE_URL } from '@woocommerce/block-settings';
|
||||
|
||||
const shortDescription = __(
|
||||
'Fly your WordPress banner with this beauty! Deck out your office space or add it to your kids walls. This banner will spruce up any space it’s hung!',
|
||||
'woocommerce'
|
||||
);
|
||||
|
||||
export const previewProducts = [
|
||||
{
|
||||
id: 1,
|
||||
name: 'WordPress Pennant',
|
||||
variation: '',
|
||||
permalink: 'https://example.org',
|
||||
sku: 'wp-pennant',
|
||||
short_description: shortDescription,
|
||||
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.',
|
||||
price: '7.99',
|
||||
price_html:
|
||||
'<span class="woocommerce-Price-amount amount"><span class="woocommerce-Price-currencySymbol">$</span>7.99</span>',
|
||||
images: [
|
||||
{
|
||||
id: 1,
|
||||
src: WC_BLOCKS_IMAGE_URL + 'previews/pennant.jpg',
|
||||
thumbnail: WC_BLOCKS_IMAGE_URL + 'previews/pennant.jpg',
|
||||
name: 'pennant-1.jpg',
|
||||
alt: 'WordPress Pennant',
|
||||
srcset: '',
|
||||
sizes: '',
|
||||
},
|
||||
],
|
||||
average_rating: 5,
|
||||
categories: [
|
||||
{
|
||||
id: 1,
|
||||
name: 'Decor',
|
||||
slug: 'decor',
|
||||
link: 'https://example.org',
|
||||
},
|
||||
],
|
||||
review_count: 1,
|
||||
prices: {
|
||||
currency_code: 'GBP',
|
||||
decimal_separator: '.',
|
||||
thousand_separator: ',',
|
||||
decimals: 2,
|
||||
price_prefix: '£',
|
||||
price_suffix: '',
|
||||
price: '7.99',
|
||||
regular_price: '9.99',
|
||||
sale_price: '7.99',
|
||||
price_range: null,
|
||||
},
|
||||
add_to_cart: {
|
||||
text: __( 'Add to cart', 'woocommerce' ),
|
||||
description: __( 'Add to cart', 'woocommerce' ),
|
||||
},
|
||||
has_options: false,
|
||||
is_purchasable: true,
|
||||
is_in_stock: true,
|
||||
on_sale: true,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,56 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { __ } from '@wordpress/i18n';
|
||||
import { blocksConfig } from '@woocommerce/block-settings';
|
||||
|
||||
export const previewReviews = [
|
||||
{
|
||||
id: 1,
|
||||
date_created: '2019-07-15T17:05:04',
|
||||
formatted_date_created: __(
|
||||
'July 15, 2019',
|
||||
'woocommerce'
|
||||
),
|
||||
date_created_gmt: '2019-07-15T15:05:04',
|
||||
product_id: 0,
|
||||
product_name: __( 'WordPress Pennant', 'woocommerce' ),
|
||||
product_permalink: '#',
|
||||
/* translators: An example person name used for the block previews. */
|
||||
reviewer: __( 'Alice', 'woocommerce' ),
|
||||
review: `<p>${ __(
|
||||
"I bought this product last week and I'm very happy with it.",
|
||||
'woocommerce'
|
||||
) }</p>\n`,
|
||||
reviewer_avatar_urls: {
|
||||
48: blocksConfig.defaultAvatar,
|
||||
96: blocksConfig.defaultAvatar,
|
||||
},
|
||||
rating: 5,
|
||||
verified: true,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
date_created: '2019-07-12T12:39:39',
|
||||
formatted_date_created: __(
|
||||
'July 12, 2019',
|
||||
'woocommerce'
|
||||
),
|
||||
date_created_gmt: '2019-07-12T10:39:39',
|
||||
product_id: 0,
|
||||
product_name: __( 'WordPress Pennant', 'woocommerce' ),
|
||||
product_permalink: '#',
|
||||
/* translators: An example person name used for the block previews. */
|
||||
reviewer: __( 'Bob', 'woocommerce' ),
|
||||
review: `<p>${ __(
|
||||
'This product is awesome, I love it!',
|
||||
'woocommerce'
|
||||
) }</p>\n`,
|
||||
reviewer_avatar_urls: {
|
||||
48: blocksConfig.defaultAvatar,
|
||||
96: blocksConfig.defaultAvatar,
|
||||
},
|
||||
rating: null,
|
||||
verified: false,
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,14 @@
|
||||
export const previewSavedPaymentMethods = {
|
||||
cc: [
|
||||
{
|
||||
method: {
|
||||
gateway: 'credit-card',
|
||||
last4: '5678',
|
||||
brand: 'Visa',
|
||||
},
|
||||
expires: '12/20',
|
||||
is_default: false,
|
||||
tokenId: '1',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,80 @@
|
||||
/**
|
||||
* External dependencies
|
||||
*/
|
||||
import { __, _x } from '@wordpress/i18n';
|
||||
import type { CartResponseShippingRate } from '@woocommerce/types';
|
||||
|
||||
export const previewShippingRates: CartResponseShippingRate[] = [
|
||||
{
|
||||
destination: {
|
||||
address_1: '',
|
||||
address_2: '',
|
||||
city: '',
|
||||
state: '',
|
||||
postcode: '',
|
||||
country: '',
|
||||
},
|
||||
package_id: 0,
|
||||
name: __( 'Shipping', 'woo-gutenberg-products-block' ),
|
||||
items: [
|
||||
{
|
||||
key: '33e75ff09dd601bbe69f351039152189',
|
||||
name: _x(
|
||||
'Beanie with Logo',
|
||||
'example product in Cart Block',
|
||||
'woo-gutenberg-products-block'
|
||||
),
|
||||
quantity: 2,
|
||||
},
|
||||
{
|
||||
key: '6512bd43d9caa6e02c990b0a82652dca',
|
||||
name: _x(
|
||||
'Beanie',
|
||||
'example product in Cart Block',
|
||||
'woo-gutenberg-products-block'
|
||||
),
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
shipping_rates: [
|
||||
{
|
||||
currency_code: 'USD',
|
||||
currency_symbol: '$',
|
||||
currency_minor_unit: 2,
|
||||
currency_decimal_separator: '.',
|
||||
currency_thousand_separator: ',',
|
||||
currency_prefix: '$',
|
||||
currency_suffix: '',
|
||||
name: __( 'Free shipping', 'woo-gutenberg-products-block' ),
|
||||
description: '',
|
||||
delivery_time: '',
|
||||
price: '000',
|
||||
taxes: '0',
|
||||
rate_id: 'free_shipping:1',
|
||||
instance_id: 0,
|
||||
meta_data: [],
|
||||
method_id: 'flat_rate',
|
||||
selected: true,
|
||||
},
|
||||
{
|
||||
currency_code: 'USD',
|
||||
currency_symbol: '$',
|
||||
currency_minor_unit: 2,
|
||||
currency_decimal_separator: '.',
|
||||
currency_thousand_separator: ',',
|
||||
currency_prefix: '$',
|
||||
currency_suffix: '',
|
||||
name: __( 'Local pickup', 'woo-gutenberg-products-block' ),
|
||||
description: '',
|
||||
delivery_time: '',
|
||||
price: '200',
|
||||
taxes: '0',
|
||||
rate_id: 'local_pickup:1',
|
||||
instance_id: 1,
|
||||
meta_data: [],
|
||||
method_id: 'local_pickup',
|
||||
selected: false,
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
@@ -0,0 +1,11 @@
|
||||
export const singleProductBlockPreview = (
|
||||
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 230 100">
|
||||
<path
|
||||
fill="#E1E3E6"
|
||||
d="M76 0h11v6H76zm0 11h88v11H76zm0 16h28v6H76zm0 17h154v28H76zm0 39h22v17H76zm28 0h44v17h-44zM0 0h66v66H0z"
|
||||
style={ {
|
||||
width: '100%',
|
||||
} }
|
||||
/>
|
||||
</svg>
|
||||
);
|
||||
Reference in New Issue
Block a user