Rename collection to shipping to reflect the block purpose

This commit is contained in:
Mike Jolley 2022-10-20 11:48:46 +01:00 committed by Nadir Seghir
parent 87c51d822f
commit 82e9155167
21 changed files with 101 additions and 70 deletions

View File

@ -43,7 +43,7 @@ export const Edit = ( {
[ 'woocommerce/checkout-contact-information-block', {}, [] ], [ 'woocommerce/checkout-contact-information-block', {}, [] ],
...[ ...[
isExperimentalBuild() isExperimentalBuild()
? [ 'woocommerce/checkout-collection-method-block', {}, [] ] ? [ 'woocommerce/checkout-shipping-method-block', {}, [] ]
: null, : null,
], ],
...[ ...[

View File

@ -47,7 +47,7 @@ export const Edit = ( {
attributes={ attributes } attributes={ attributes }
setAttributes={ setAttributes } setAttributes={ setAttributes }
className={ classnames( className={ classnames(
'wc-block-checkout__collection-method', 'wc-block-checkout__shipping-method',
className className
) } ) }
> >

View File

@ -34,7 +34,7 @@ export default {
}, },
shippingText: { shippingText: {
type: 'string', type: 'string',
default: __( 'Delivery', 'woo-gutenberg-products-block' ), default: __( 'Shipping', 'woo-gutenberg-products-block' ),
}, },
lock: { lock: {
type: 'object', type: 'object',

View File

@ -1,8 +1,8 @@
{ {
"name": "woocommerce/checkout-collection-method-block", "name": "woocommerce/checkout-shipping-method-block",
"version": "1.0.0", "version": "1.0.0",
"title": "Shipping Method", "title": "Shipping Method",
"description": "Select between delivery or collection.", "description": "Select between shipping or local pickup.",
"category": "woocommerce", "category": "woocommerce",
"supports": { "supports": {
"align": false, "align": false,

View File

@ -33,19 +33,22 @@ const LocalPickupSelector = ( {
return ( return (
<Radio <Radio
value="pickup" value="pickup"
className={ classnames( 'wc-block-checkout__collection-item', { className={ classnames(
'wc-block-checkout__collection-item--selected': 'wc-block-checkout__shipping-method-option',
checked === 'pickup', {
} ) } 'wc-block-checkout__shipping-method-option--selected':
checked === 'pickup',
}
) }
> >
{ showIcon === true && ( { showIcon === true && (
<Icon <Icon
icon={ store } icon={ store }
size={ 28 } size={ 28 }
className="wc-block-checkout__collection-item-icon" className="wc-block-checkout__shipping-method-option-icon"
/> />
) } ) }
<span className="wc-block-checkout__collection-item-title"> <span className="wc-block-checkout__shipping-method-option-title">
{ toggleText } { toggleText }
</span> </span>
{ showPrice === true && ( { showPrice === true && (
@ -70,7 +73,7 @@ const ShippingSelector = ( {
} ) => { } ) => {
const Price = const Price =
rate.min === undefined ? ( rate.min === undefined ? (
<span className="wc-block-checkout__collection-item-price"> <span className="wc-block-checkout__shipping-method-option-price">
{ __( { __(
'calculated with an address', 'calculated with an address',
'woo-gutenberg-products-block' 'woo-gutenberg-products-block'
@ -83,19 +86,22 @@ const ShippingSelector = ( {
return ( return (
<Radio <Radio
value="shipping" value="shipping"
className={ classnames( 'wc-block-checkout__collection-item', { className={ classnames(
'wc-block-checkout__collection-item--selected': 'wc-block-checkout__shipping-method-option',
checked === 'shipping', {
} ) } 'wc-block-checkout__shipping-method-option--selected':
checked === 'shipping',
}
) }
> >
{ showIcon === true && ( { showIcon === true && (
<Icon <Icon
icon={ shipping } icon={ shipping }
size={ 28 } size={ 28 }
className="wc-block-checkout__collection-item-icon" className="wc-block-checkout__shipping-method-option-icon"
/> />
) } ) }
<span className="wc-block-checkout__collection-item-title"> <span className="wc-block-checkout__shipping-method-option-title">
{ toggleText } { toggleText }
</span> </span>
{ showPrice === true && Price } { showPrice === true && Price }
@ -121,8 +127,8 @@ const Block = ( {
return ( return (
<RadioGroup <RadioGroup
id="collection-method" id="shipping-method"
className="wc-block-checkout__collection-method-container" className="wc-block-checkout__shipping-method-container"
label="options" label="options"
onChange={ onChange } onChange={ onChange }
checked={ checked } checked={ checked }

View File

@ -52,22 +52,25 @@ const LocalPickupSelector = ( {
return ( return (
<Radio <Radio
value="pickup" value="pickup"
className={ classnames( 'wc-block-checkout__collection-item', { className={ classnames(
'wc-block-checkout__collection-item--selected': 'wc-block-checkout__shipping-method-option',
checked === 'pickup', {
} ) } 'wc-block-checkout__shipping-method-option--selected':
checked === 'pickup',
}
) }
> >
{ showIcon === true && ( { showIcon === true && (
<Icon <Icon
icon={ store } icon={ store }
size={ 28 } size={ 28 }
className="wc-block-checkout__collection-item-icon" className="wc-block-checkout__shipping-method-option-icon"
/> />
) } ) }
<RichText <RichText
value={ toggleText } value={ toggleText }
tagName="span" tagName="span"
className="wc-block-checkout__collection-item-title" className="wc-block-checkout__shipping-method-option-title"
onChange={ ( value ) => onChange={ ( value ) =>
setAttributes( { localPickupText: value } ) setAttributes( { localPickupText: value } )
} }
@ -98,7 +101,7 @@ const ShippingSelector = ( {
} ) => { } ) => {
const Price = const Price =
rate.min === undefined ? ( rate.min === undefined ? (
<span className="wc-block-checkout__collection-item-price"> <span className="wc-block-checkout__shipping-method-option-price">
{ __( { __(
'calculated with an address', 'calculated with an address',
'woo-gutenberg-products-block' 'woo-gutenberg-products-block'
@ -111,22 +114,25 @@ const ShippingSelector = ( {
return ( return (
<Radio <Radio
value="shipping" value="shipping"
className={ classnames( 'wc-block-checkout__collection-item', { className={ classnames(
'wc-block-checkout__collection-item--selected': 'wc-block-checkout__shipping-method-option',
checked === 'shipping', {
} ) } 'wc-block-checkout__shipping-method-option--selected':
checked === 'shipping',
}
) }
> >
{ showIcon === true && ( { showIcon === true && (
<Icon <Icon
icon={ shipping } icon={ shipping }
size={ 28 } size={ 28 }
className="wc-block-checkout__collection-item-icon" className="wc-block-checkout__shipping-method-option-icon"
/> />
) } ) }
<RichText <RichText
value={ toggleText } value={ toggleText }
tagName="span" tagName="span"
className="wc-block-checkout__collection-item-title" className="wc-block-checkout__shipping-method-option-title"
onChange={ ( value ) => onChange={ ( value ) =>
setAttributes( { shippingText: value } ) setAttributes( { shippingText: value } )
} }
@ -193,7 +199,7 @@ export const Edit = ( {
attributes={ attributes } attributes={ attributes }
setAttributes={ setAttributes } setAttributes={ setAttributes }
className={ classnames( className={ classnames(
'wc-block-checkout__collection-method', 'wc-block-checkout__shipping-method',
className className
) } ) }
> >
@ -234,8 +240,8 @@ export const Edit = ( {
</PanelBody> </PanelBody>
</InspectorControls> </InspectorControls>
<RadioGroup <RadioGroup
id="collection-method" id="shipping-method"
className="wc-block-checkout__collection-method-container" className="wc-block-checkout__shipping-method-container"
label="options" label="options"
onChange={ changeView } onChange={ changeView }
checked={ prefersCollection ? 'pickup' : 'shipping' } checked={ prefersCollection ? 'pickup' : 'shipping' }
@ -261,7 +267,7 @@ export const Edit = ( {
toggleText={ localPickupText } toggleText={ localPickupText }
/> />
</RadioGroup> </RadioGroup>
<AdditionalFields block={ innerBlockAreas.COLLECTION_METHOD } /> <AdditionalFields block={ innerBlockAreas.SHIPPING_METHOD } />
</FormStepBlock> </FormStepBlock>
); );
}; };

View File

@ -71,10 +71,10 @@ const FrontendBlock = ( {
return ( return (
<FormStep <FormStep
id="collection-method" id="shipping-method"
disabled={ checkoutIsProcessing } disabled={ checkoutIsProcessing }
className={ classnames( className={ classnames(
'wc-block-checkout__collection-method', 'wc-block-checkout__shipping-method',
className className
) } ) }
title={ title } title={ title }

View File

@ -10,7 +10,7 @@ import { registerExperimentalBlockType } from '@woocommerce/block-settings';
import { Edit, Save } from './edit'; import { Edit, Save } from './edit';
import attributes from './attributes'; import attributes from './attributes';
registerExperimentalBlockType( 'woocommerce/checkout-collection-method-block', { registerExperimentalBlockType( 'woocommerce/checkout-shipping-method-block', {
icon: { icon: {
src: ( src: (
<Icon <Icon

View File

@ -36,7 +36,7 @@ export const RatePrice = ( {
); );
return ( return (
<span className="wc-block-checkout__collection-item-price"> <span className="wc-block-checkout__shipping-method-option-price">
{ minRatePrice === maxRatePrice { minRatePrice === maxRatePrice
? priceElement ? priceElement
: createInterpolateElement( : createInterpolateElement(

View File

@ -1,11 +1,11 @@
.wc-block-checkout__collection-method-container { .wc-block-checkout__shipping-method-container {
width: 100%; width: 100%;
display: flex; display: flex;
gap: $gap; gap: $gap;
justify-content: space-between; justify-content: space-between;
} }
.wc-block-checkout__collection-item { .wc-block-checkout__shipping-method-option {
flex-grow: 1; flex-grow: 1;
display: flex; display: flex;
flex-direction: column; flex-direction: column;
@ -20,21 +20,21 @@
background-color: transparent; background-color: transparent;
border: none; border: none;
outline: 1px solid currentColor; outline: 1px solid currentColor;
&.wc-block-checkout__collection-item--selected { &.wc-block-checkout__shipping-method-option--selected {
outline-width: 2px; outline-width: 2px;
} }
} }
.wc-block-checkout__collection-item-icon { .wc-block-checkout__shipping-method-option-icon {
fill: currentColor; fill: currentColor;
} }
.wc-block-checkout__collection-item-title { .wc-block-checkout__shipping-method-option-title {
@include font-size(regular, 1rem); @include font-size(regular, 1rem);
font-weight: bold; font-weight: bold;
} }
.wc-block-checkout__collection-item-price { .wc-block-checkout__shipping-method-option-price {
@include font-size(small, 1rem); @include font-size(small, 1rem);
em { em {

View File

@ -2,7 +2,7 @@
"name": "woocommerce/checkout-shipping-methods-block", "name": "woocommerce/checkout-shipping-methods-block",
"version": "1.0.0", "version": "1.0.0",
"title": "Shipping Options", "title": "Shipping Options",
"description": "Shipping options for your store.", "description": "Display shipping options and rates for your store.",
"category": "woocommerce", "category": "woocommerce",
"supports": { "supports": {
"align": false, "align": false,

View File

@ -9,8 +9,8 @@ import CHECKOUT_FIELDS from './checkout-fields-block/block.json';
import CHECKOUT_ORDER_NOTE from './checkout-order-note-block/block.json'; import CHECKOUT_ORDER_NOTE from './checkout-order-note-block/block.json';
import CHECKOUT_PAYMENT from './checkout-payment-block/block.json'; import CHECKOUT_PAYMENT from './checkout-payment-block/block.json';
import CHECKOUT_SHIPPING_ADDRESS from './checkout-shipping-address-block/block.json'; import CHECKOUT_SHIPPING_ADDRESS from './checkout-shipping-address-block/block.json';
import CHECKOUT_SHIPPING_METHOD from './checkout-shipping-method-block/block.json';
import CHECKOUT_SHIPPING_METHODS from './checkout-shipping-methods-block/block.json'; import CHECKOUT_SHIPPING_METHODS from './checkout-shipping-methods-block/block.json';
import CHECKOUT_COLLECTION_METHOD from './checkout-collection-method-block/block.json';
import CHECKOUT_PICKUP_LOCATION from './checkout-pickup-options-block/block.json'; import CHECKOUT_PICKUP_LOCATION from './checkout-pickup-options-block/block.json';
import CHECKOUT_TERMS from './checkout-terms-block/block.json'; import CHECKOUT_TERMS from './checkout-terms-block/block.json';
import CHECKOUT_TOTALS from './checkout-totals-block/block.json'; import CHECKOUT_TOTALS from './checkout-totals-block/block.json';
@ -31,8 +31,10 @@ export default {
CHECKOUT_FIELDS, CHECKOUT_FIELDS,
CHECKOUT_ORDER_NOTE, CHECKOUT_ORDER_NOTE,
CHECKOUT_PAYMENT, CHECKOUT_PAYMENT,
CHECKOUT_SHIPPING_METHOD,
CHECKOUT_SHIPPING_ADDRESS, CHECKOUT_SHIPPING_ADDRESS,
CHECKOUT_SHIPPING_METHODS, CHECKOUT_SHIPPING_METHODS,
CHECKOUT_PICKUP_LOCATION,
CHECKOUT_TERMS, CHECKOUT_TERMS,
CHECKOUT_TOTALS, CHECKOUT_TOTALS,
CHECKOUT_ORDER_SUMMARY, CHECKOUT_ORDER_SUMMARY,
@ -43,6 +45,4 @@ export default {
CHECKOUT_ORDER_SUMMARY_COUPON_FORM, CHECKOUT_ORDER_SUMMARY_COUPON_FORM,
CHECKOUT_ORDER_SUMMARY_TAXES, CHECKOUT_ORDER_SUMMARY_TAXES,
CHECKOUT_ORDER_SUMMARY_CART_ITEMS, CHECKOUT_ORDER_SUMMARY_CART_ITEMS,
CHECKOUT_COLLECTION_METHOD,
CHECKOUT_PICKUP_LOCATION,
}; };

View File

@ -12,8 +12,8 @@ import './checkout-order-note-block';
import './checkout-order-summary-block'; import './checkout-order-summary-block';
import './checkout-payment-block'; import './checkout-payment-block';
import './checkout-express-payment-block'; import './checkout-express-payment-block';
import './checkout-shipping-method-block';
import './checkout-shipping-methods-block'; import './checkout-shipping-methods-block';
import './checkout-collection-method-block';
import './checkout-pickup-options-block'; import './checkout-pickup-options-block';
import './checkout-order-summary-subtotal'; import './checkout-order-summary-subtotal';
import './checkout-order-summary-fee'; import './checkout-order-summary-fee';

View File

@ -50,11 +50,11 @@ registerCheckoutBlock( {
if ( isExperimentalBuild() ) { if ( isExperimentalBuild() ) {
registerCheckoutBlock( { registerCheckoutBlock( {
metadata: metadata.CHECKOUT_COLLECTION_METHOD, metadata: metadata.CHECKOUT_SHIPPING_METHOD,
component: lazy( component: lazy(
() => () =>
import( import(
/* webpackChunkName: "checkout-blocks/collection-method" */ './checkout-collection-method-block/frontend' /* webpackChunkName: "checkout-blocks/shipping-method" */ './checkout-shipping-method-block/frontend'
) )
), ),
} ); } );

View File

@ -38122,6 +38122,16 @@
"inherits": "2.0.3" "inherits": "2.0.3"
} }
}, },
"node_modules/node-pty": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/node-pty/-/node-pty-0.9.0.tgz",
"integrity": "sha512-MBnCQl83FTYOu7B4xWw10AW77AAh7ThCE1VXEv+JeWj8mSpGo+0bwgsV+b23ljBFwEM9OmsOv3kM27iUPPm84g==",
"hasInstallScript": true,
"optional": true,
"dependencies": {
"nan": "^2.14.0"
}
},
"node_modules/node-releases": { "node_modules/node-releases": {
"version": "2.0.4", "version": "2.0.4",
"license": "MIT" "license": "MIT"
@ -76698,6 +76708,15 @@
} }
} }
}, },
"node-pty": {
"version": "0.9.0",
"resolved": "https://registry.npmjs.org/node-pty/-/node-pty-0.9.0.tgz",
"integrity": "sha512-MBnCQl83FTYOu7B4xWw10AW77AAh7ThCE1VXEv+JeWj8mSpGo+0bwgsV+b23ljBFwEM9OmsOv3kM27iUPPm84g==",
"optional": true,
"requires": {
"nan": "^2.14.0"
}
},
"node-releases": { "node-releases": {
"version": "2.0.4" "version": "2.0.4"
}, },

View File

@ -12,8 +12,8 @@ export enum innerBlockAreas {
CONTACT_INFORMATION = 'woocommerce/checkout-contact-information-block', CONTACT_INFORMATION = 'woocommerce/checkout-contact-information-block',
SHIPPING_ADDRESS = 'woocommerce/checkout-shipping-address-block', SHIPPING_ADDRESS = 'woocommerce/checkout-shipping-address-block',
BILLING_ADDRESS = 'woocommerce/checkout-billing-address-block', BILLING_ADDRESS = 'woocommerce/checkout-billing-address-block',
SHIPPING_METHOD = 'woocommerce/checkout-shipping-method-block',
SHIPPING_METHODS = 'woocommerce/checkout-shipping-methods-block', SHIPPING_METHODS = 'woocommerce/checkout-shipping-methods-block',
COLLECTION_METHOD = 'woocommerce/checkout-collection-method-block',
PICKUP_LOCATION = 'woocommerce/checkout-pickup-options-block', PICKUP_LOCATION = 'woocommerce/checkout-pickup-options-block',
PAYMENT_METHODS = 'woocommerce/checkout-payment-methods-block', PAYMENT_METHODS = 'woocommerce/checkout-payment-methods-block',
CART = 'woocommerce/cart', CART = 'woocommerce/cart',

View File

@ -444,7 +444,7 @@ class Checkout extends AbstractBlock {
'CheckoutPaymentBlock', 'CheckoutPaymentBlock',
'CheckoutShippingAddressBlock', 'CheckoutShippingAddressBlock',
'CheckoutShippingMethodsBlock', 'CheckoutShippingMethodsBlock',
'CheckoutCollectionMethodBlock', 'CheckoutShippingMethodBlock',
'CheckoutPickupOptionsBlock', 'CheckoutPickupOptionsBlock',
'CheckoutTermsBlock', 'CheckoutTermsBlock',
'CheckoutTotalsBlock', 'CheckoutTotalsBlock',

View File

@ -1,14 +0,0 @@
<?php
namespace Automattic\WooCommerce\Blocks\BlockTypes;
/**
* CheckoutCollectionMethodBlock class.
*/
class CheckoutCollectionMethodBlock extends AbstractInnerBlock {
/**
* Block name.
*
* @var string
*/
protected $block_name = 'checkout-collection-method-block';
}

View File

@ -0,0 +1,14 @@
<?php
namespace Automattic\WooCommerce\Blocks\BlockTypes;
/**
* CheckoutShippingMethodBlock class.
*/
class CheckoutShippingMethodBlock extends AbstractInnerBlock {
/**
* Block name.
*
* @var string
*/
protected $block_name = 'checkout-shipping-method-block';
}