Remove Shipping calculator settings and link to the WooCommerce admin settings (https://github.com/woocommerce/woocommerce-blocks/pull/11184)
* Remove block level options in favour of settings * Remove calculator toggle test * Update assets/js/blocks/cart/inner-blocks/cart-order-summary-shipping/block.tsx Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com> * Remove unused attributes --------- Co-authored-by: Thomas Roberts <5656702+opr@users.noreply.github.com>
This commit is contained in:
parent
cffea366a5
commit
2044798af6
|
@ -1,18 +0,0 @@
|
||||||
/**
|
|
||||||
* External dependencies
|
|
||||||
*/
|
|
||||||
import { getSetting } from '@woocommerce/settings';
|
|
||||||
|
|
||||||
export default {
|
|
||||||
isShippingCalculatorEnabled: {
|
|
||||||
type: 'boolean',
|
|
||||||
default: getSetting( 'isShippingCalculatorEnabled', true ),
|
|
||||||
},
|
|
||||||
lock: {
|
|
||||||
type: 'object',
|
|
||||||
default: {
|
|
||||||
move: false,
|
|
||||||
remove: true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
|
|
@ -5,14 +5,9 @@ import { TotalsShipping } from '@woocommerce/base-components/cart-checkout';
|
||||||
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
|
import { getCurrencyFromPriceResponse } from '@woocommerce/price-format';
|
||||||
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
import { useStoreCart } from '@woocommerce/base-context/hooks';
|
||||||
import { TotalsWrapper } from '@woocommerce/blocks-checkout';
|
import { TotalsWrapper } from '@woocommerce/blocks-checkout';
|
||||||
|
import { getSetting } from '@woocommerce/settings';
|
||||||
|
|
||||||
const Block = ( {
|
const Block = ( { className }: { className: string } ): JSX.Element | null => {
|
||||||
className,
|
|
||||||
isShippingCalculatorEnabled,
|
|
||||||
}: {
|
|
||||||
className: string;
|
|
||||||
isShippingCalculatorEnabled: boolean;
|
|
||||||
} ): JSX.Element | null => {
|
|
||||||
const { cartTotals, cartNeedsShipping } = useStoreCart();
|
const { cartTotals, cartNeedsShipping } = useStoreCart();
|
||||||
|
|
||||||
if ( ! cartNeedsShipping ) {
|
if ( ! cartNeedsShipping ) {
|
||||||
|
@ -24,7 +19,10 @@ const Block = ( {
|
||||||
return (
|
return (
|
||||||
<TotalsWrapper className={ className }>
|
<TotalsWrapper className={ className }>
|
||||||
<TotalsShipping
|
<TotalsShipping
|
||||||
showCalculator={ isShippingCalculatorEnabled }
|
showCalculator={ getSetting< boolean >(
|
||||||
|
'isShippingCalculatorEnabled',
|
||||||
|
true
|
||||||
|
) }
|
||||||
showRateSelector={ true }
|
showRateSelector={ true }
|
||||||
values={ cartTotals }
|
values={ cartTotals }
|
||||||
currency={ totalsCurrency }
|
currency={ totalsCurrency }
|
||||||
|
|
|
@ -3,8 +3,8 @@
|
||||||
*/
|
*/
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
import { useBlockProps, InspectorControls } from '@wordpress/block-editor';
|
||||||
import { PanelBody, ToggleControl } from '@wordpress/components';
|
import { PanelBody, ExternalLink } from '@wordpress/components';
|
||||||
import { getSetting } from '@woocommerce/settings';
|
import { ADMIN_URL, getSetting } from '@woocommerce/settings';
|
||||||
import Noninteractive from '@woocommerce/base-components/noninteractive';
|
import Noninteractive from '@woocommerce/base-components/noninteractive';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -14,19 +14,16 @@ import Block from './block';
|
||||||
|
|
||||||
export const Edit = ( {
|
export const Edit = ( {
|
||||||
attributes,
|
attributes,
|
||||||
setAttributes,
|
|
||||||
}: {
|
}: {
|
||||||
attributes: {
|
attributes: {
|
||||||
isShippingCalculatorEnabled: boolean;
|
|
||||||
className: string;
|
className: string;
|
||||||
lock: {
|
lock: {
|
||||||
move: boolean;
|
move: boolean;
|
||||||
remove: boolean;
|
remove: boolean;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
|
||||||
} ): JSX.Element => {
|
} ): JSX.Element => {
|
||||||
const { isShippingCalculatorEnabled, className } = attributes;
|
const { className } = attributes;
|
||||||
const shippingEnabled = getSetting( 'shippingEnabled', true );
|
const shippingEnabled = getSetting( 'shippingEnabled', true );
|
||||||
const blockProps = useBlockProps();
|
const blockProps = useBlockProps();
|
||||||
|
|
||||||
|
@ -36,35 +33,29 @@ export const Edit = ( {
|
||||||
{ !! shippingEnabled && (
|
{ !! shippingEnabled && (
|
||||||
<PanelBody
|
<PanelBody
|
||||||
title={ __(
|
title={ __(
|
||||||
'Shipping rates',
|
'Shipping Calculations',
|
||||||
'woo-gutenberg-products-block'
|
'woo-gutenberg-products-block'
|
||||||
) }
|
) }
|
||||||
>
|
>
|
||||||
<ToggleControl
|
<p className="wc-block-checkout__controls-text">
|
||||||
label={ __(
|
{ __(
|
||||||
'Shipping calculator',
|
'Options that control shipping can be managed in your store settings.',
|
||||||
'woo-gutenberg-products-block'
|
'woo-gutenberg-products-block'
|
||||||
) }
|
) }
|
||||||
help={ __(
|
</p>
|
||||||
'Allow customers to estimate shipping by entering their address.',
|
<ExternalLink
|
||||||
|
href={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=shipping§ion=options` }
|
||||||
|
>
|
||||||
|
{ __(
|
||||||
|
'Manage shipping options',
|
||||||
'woo-gutenberg-products-block'
|
'woo-gutenberg-products-block'
|
||||||
) }
|
) }
|
||||||
checked={ isShippingCalculatorEnabled }
|
</ExternalLink>{ ' ' }
|
||||||
onChange={ () =>
|
|
||||||
setAttributes( {
|
|
||||||
isShippingCalculatorEnabled:
|
|
||||||
! isShippingCalculatorEnabled,
|
|
||||||
} )
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
) }
|
) }
|
||||||
</InspectorControls>
|
</InspectorControls>
|
||||||
<Noninteractive>
|
<Noninteractive>
|
||||||
<Block
|
<Block className={ className } />
|
||||||
className={ className }
|
|
||||||
isShippingCalculatorEnabled={ isShippingCalculatorEnabled }
|
|
||||||
/>
|
|
||||||
</Noninteractive>
|
</Noninteractive>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
/**
|
|
||||||
* External dependencies
|
|
||||||
*/
|
|
||||||
import { withFilteredAttributes } from '@woocommerce/shared-hocs';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import Block from './block';
|
import Block from './block';
|
||||||
import attributes from './attributes';
|
|
||||||
|
|
||||||
export default withFilteredAttributes( attributes )( Block );
|
export default Block;
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { registerBlockType } from '@wordpress/blocks';
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
*/
|
*/
|
||||||
import { Edit, Save } from './edit';
|
import { Edit, Save } from './edit';
|
||||||
import attributes from './attributes';
|
|
||||||
|
|
||||||
registerBlockType( 'woocommerce/cart-order-summary-shipping-block', {
|
registerBlockType( 'woocommerce/cart-order-summary-shipping-block', {
|
||||||
icon: {
|
icon: {
|
||||||
|
@ -20,7 +19,6 @@ registerBlockType( 'woocommerce/cart-order-summary-shipping-block', {
|
||||||
/>
|
/>
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
attributes,
|
|
||||||
edit: Edit,
|
edit: Edit,
|
||||||
save: Save,
|
save: Save,
|
||||||
} );
|
} );
|
||||||
|
|
|
@ -40,15 +40,10 @@ jest.mock( '@wordpress/compose', () => ( {
|
||||||
const CartBlock = ( {
|
const CartBlock = ( {
|
||||||
attributes = {
|
attributes = {
|
||||||
showRateAfterTaxName: false,
|
showRateAfterTaxName: false,
|
||||||
isShippingCalculatorEnabled: false,
|
|
||||||
checkoutPageId: 0,
|
checkoutPageId: 0,
|
||||||
},
|
},
|
||||||
} ) => {
|
} ) => {
|
||||||
const {
|
const { showRateAfterTaxName, checkoutPageId } = attributes;
|
||||||
showRateAfterTaxName,
|
|
||||||
isShippingCalculatorEnabled,
|
|
||||||
checkoutPageId,
|
|
||||||
} = attributes;
|
|
||||||
return (
|
return (
|
||||||
<Cart attributes={ attributes }>
|
<Cart attributes={ attributes }>
|
||||||
<FilledCart>
|
<FilledCart>
|
||||||
|
@ -59,11 +54,7 @@ const CartBlock = ( {
|
||||||
<OrderSummaryBlock>
|
<OrderSummaryBlock>
|
||||||
<OrderSummaryHeadingBlock />
|
<OrderSummaryHeadingBlock />
|
||||||
<OrderSummarySubtotalBlock />
|
<OrderSummarySubtotalBlock />
|
||||||
<OrderSummaryShippingBlock
|
<OrderSummaryShippingBlock />
|
||||||
isShippingCalculatorEnabled={
|
|
||||||
isShippingCalculatorEnabled
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
<OrderSummaryTaxesBlock
|
<OrderSummaryTaxesBlock
|
||||||
showRateAfterTaxName={ showRateAfterTaxName }
|
showRateAfterTaxName={ showRateAfterTaxName }
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -49,7 +49,7 @@ export const Edit = ( {
|
||||||
>
|
>
|
||||||
<p className="wc-block-checkout__controls-text">
|
<p className="wc-block-checkout__controls-text">
|
||||||
{ __(
|
{ __(
|
||||||
'Account creation and guest checkout settings can be managed in the WooCommerce settings.',
|
'Account creation and guest checkout settings can be managed in your store settings.',
|
||||||
'woo-gutenberg-products-block'
|
'woo-gutenberg-products-block'
|
||||||
) }
|
) }
|
||||||
</p>
|
</p>
|
||||||
|
|
|
@ -44,8 +44,4 @@ export default {
|
||||||
remove: true,
|
remove: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
shippingCostRequiresAddress: {
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,10 +19,6 @@
|
||||||
"remove": true,
|
"remove": true,
|
||||||
"move": true
|
"move": true
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"shippingCostRequiresAddress": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"parent": [ "woocommerce/checkout-fields-block" ],
|
"parent": [ "woocommerce/checkout-fields-block" ],
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { useEffect } from '@wordpress/element';
|
||||||
import { CART_STORE_KEY, VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
import { CART_STORE_KEY, VALIDATION_STORE_KEY } from '@woocommerce/block-data';
|
||||||
import { useDispatch, useSelect } from '@wordpress/data';
|
import { useDispatch, useSelect } from '@wordpress/data';
|
||||||
import { isPackageRateCollectable } from '@woocommerce/base-utils';
|
import { isPackageRateCollectable } from '@woocommerce/base-utils';
|
||||||
|
import { getSetting } from '@woocommerce/settings';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -164,17 +165,19 @@ const Block = ( {
|
||||||
showIcon,
|
showIcon,
|
||||||
localPickupText,
|
localPickupText,
|
||||||
shippingText,
|
shippingText,
|
||||||
shippingCostRequiresAddress = false,
|
|
||||||
}: {
|
}: {
|
||||||
checked: string;
|
checked: string;
|
||||||
onChange: ( value: string ) => void;
|
onChange: ( value: string ) => void;
|
||||||
showPrice: boolean;
|
showPrice: boolean;
|
||||||
showIcon: boolean;
|
showIcon: boolean;
|
||||||
shippingCostRequiresAddress: boolean;
|
|
||||||
localPickupText: string;
|
localPickupText: string;
|
||||||
shippingText: string;
|
shippingText: string;
|
||||||
} ): JSX.Element | null => {
|
} ): JSX.Element | null => {
|
||||||
const { shippingRates } = useShippingData();
|
const { shippingRates } = useShippingData();
|
||||||
|
const shippingCostRequiresAddress = getSetting< boolean >(
|
||||||
|
'shippingCostRequiresAddress',
|
||||||
|
false
|
||||||
|
);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<RadioGroup
|
<RadioGroup
|
||||||
|
|
|
@ -23,8 +23,6 @@ import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
||||||
import { useDispatch, useSelect } from '@wordpress/data';
|
import { useDispatch, useSelect } from '@wordpress/data';
|
||||||
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
import { CHECKOUT_STORE_KEY } from '@woocommerce/block-data';
|
||||||
import ExternalLinkCard from '@woocommerce/editor-components/external-link-card';
|
import ExternalLinkCard from '@woocommerce/editor-components/external-link-card';
|
||||||
import { Attributes } from '@woocommerce/blocks/checkout/types';
|
|
||||||
import { updateAttributeInSiblingBlock } from '@woocommerce/utils';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -154,9 +152,7 @@ const ShippingSelector = ( {
|
||||||
export const Edit = ( {
|
export const Edit = ( {
|
||||||
attributes,
|
attributes,
|
||||||
setAttributes,
|
setAttributes,
|
||||||
clientId,
|
|
||||||
}: {
|
}: {
|
||||||
clientId: string;
|
|
||||||
attributes: {
|
attributes: {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
|
@ -167,16 +163,9 @@ export const Edit = ( {
|
||||||
showPrice: boolean;
|
showPrice: boolean;
|
||||||
showIcon: boolean;
|
showIcon: boolean;
|
||||||
className: string;
|
className: string;
|
||||||
shippingCostRequiresAddress: boolean;
|
|
||||||
};
|
};
|
||||||
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
||||||
} ): JSX.Element | null => {
|
} ): JSX.Element | null => {
|
||||||
const toggleAttribute = ( key: keyof Attributes ): void => {
|
|
||||||
const newAttributes = {} as Partial< Attributes >;
|
|
||||||
newAttributes[ key ] = ! ( attributes[ key ] as boolean );
|
|
||||||
setAttributes( newAttributes );
|
|
||||||
};
|
|
||||||
|
|
||||||
const { setPrefersCollection } = useDispatch( CHECKOUT_STORE_KEY );
|
const { setPrefersCollection } = useDispatch( CHECKOUT_STORE_KEY );
|
||||||
const { prefersCollection } = useSelect( ( select ) => {
|
const { prefersCollection } = useSelect( ( select ) => {
|
||||||
const checkoutStore = select( CHECKOUT_STORE_KEY );
|
const checkoutStore = select( CHECKOUT_STORE_KEY );
|
||||||
|
@ -221,30 +210,6 @@ export const Edit = ( {
|
||||||
) }
|
) }
|
||||||
>
|
>
|
||||||
<InspectorControls>
|
<InspectorControls>
|
||||||
<PanelBody
|
|
||||||
title={ __(
|
|
||||||
'Calculations',
|
|
||||||
'woo-gutenberg-products-block'
|
|
||||||
) }
|
|
||||||
>
|
|
||||||
<ToggleControl
|
|
||||||
label={ __(
|
|
||||||
'Hide shipping costs until an address is entered',
|
|
||||||
'woo-gutenberg-products-block'
|
|
||||||
) }
|
|
||||||
checked={ attributes.shippingCostRequiresAddress }
|
|
||||||
onChange={ ( selected ) => {
|
|
||||||
updateAttributeInSiblingBlock(
|
|
||||||
clientId,
|
|
||||||
'shippingCostRequiresAddress',
|
|
||||||
selected,
|
|
||||||
'woocommerce/checkout-shipping-methods-block'
|
|
||||||
);
|
|
||||||
|
|
||||||
toggleAttribute( 'shippingCostRequiresAddress' );
|
|
||||||
} }
|
|
||||||
/>
|
|
||||||
</PanelBody>
|
|
||||||
<PanelBody
|
<PanelBody
|
||||||
title={ __( 'Appearance', 'woo-gutenberg-products-block' ) }
|
title={ __( 'Appearance', 'woo-gutenberg-products-block' ) }
|
||||||
>
|
>
|
||||||
|
|
|
@ -25,12 +25,10 @@ const FrontendBlock = ( {
|
||||||
showIcon,
|
showIcon,
|
||||||
shippingText,
|
shippingText,
|
||||||
localPickupText,
|
localPickupText,
|
||||||
shippingCostRequiresAddress,
|
|
||||||
}: {
|
}: {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
showStepNumber: boolean;
|
showStepNumber: boolean;
|
||||||
shippingCostRequiresAddress: boolean;
|
|
||||||
children: JSX.Element;
|
children: JSX.Element;
|
||||||
className?: string;
|
className?: string;
|
||||||
showPrice: boolean;
|
showPrice: boolean;
|
||||||
|
@ -92,7 +90,6 @@ const FrontendBlock = ( {
|
||||||
showIcon={ showIcon }
|
showIcon={ showIcon }
|
||||||
localPickupText={ localPickupText }
|
localPickupText={ localPickupText }
|
||||||
shippingText={ shippingText }
|
shippingText={ shippingText }
|
||||||
shippingCostRequiresAddress={ shippingCostRequiresAddress }
|
|
||||||
/>
|
/>
|
||||||
{ children }
|
{ children }
|
||||||
</FormStep>
|
</FormStep>
|
||||||
|
|
|
@ -24,8 +24,4 @@ export default {
|
||||||
remove: true,
|
remove: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
shippingCostRequiresAddress: {
|
|
||||||
type: 'boolean',
|
|
||||||
default: false,
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -19,10 +19,6 @@
|
||||||
"remove": true,
|
"remove": true,
|
||||||
"move": true
|
"move": true
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"shippingCostRequiresAddress": {
|
|
||||||
"type": "boolean",
|
|
||||||
"default": false
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"parent": [ "woocommerce/checkout-fields-block" ],
|
"parent": [ "woocommerce/checkout-fields-block" ],
|
||||||
|
|
|
@ -4,14 +4,12 @@
|
||||||
import classnames from 'classnames';
|
import classnames from 'classnames';
|
||||||
import { __ } from '@wordpress/i18n';
|
import { __ } from '@wordpress/i18n';
|
||||||
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
import { InspectorControls, useBlockProps } from '@wordpress/block-editor';
|
||||||
import { PanelBody, ExternalLink, ToggleControl } from '@wordpress/components';
|
import { PanelBody, ExternalLink } from '@wordpress/components';
|
||||||
import { ADMIN_URL, getSetting } from '@woocommerce/settings';
|
import { ADMIN_URL, getSetting } from '@woocommerce/settings';
|
||||||
import ExternalLinkCard from '@woocommerce/editor-components/external-link-card';
|
import ExternalLinkCard from '@woocommerce/editor-components/external-link-card';
|
||||||
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
import { innerBlockAreas } from '@woocommerce/blocks-checkout';
|
||||||
import { useCheckoutAddress } from '@woocommerce/base-context/hooks';
|
import { useCheckoutAddress } from '@woocommerce/base-context/hooks';
|
||||||
import Noninteractive from '@woocommerce/base-components/noninteractive';
|
import Noninteractive from '@woocommerce/base-components/noninteractive';
|
||||||
import { Attributes } from '@woocommerce/blocks/checkout/types';
|
|
||||||
import { updateAttributeInSiblingBlock } from '@woocommerce/utils';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal dependencies
|
* Internal dependencies
|
||||||
|
@ -34,15 +32,12 @@ type shippingAdminLink = {
|
||||||
export const Edit = ( {
|
export const Edit = ( {
|
||||||
attributes,
|
attributes,
|
||||||
setAttributes,
|
setAttributes,
|
||||||
clientId,
|
|
||||||
}: {
|
}: {
|
||||||
clientId: string;
|
|
||||||
attributes: {
|
attributes: {
|
||||||
title: string;
|
title: string;
|
||||||
description: string;
|
description: string;
|
||||||
showStepNumber: boolean;
|
showStepNumber: boolean;
|
||||||
className: string;
|
className: string;
|
||||||
shippingCostRequiresAddress: boolean;
|
|
||||||
};
|
};
|
||||||
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
setAttributes: ( attributes: Record< string, unknown > ) => void;
|
||||||
} ): JSX.Element | null => {
|
} ): JSX.Element | null => {
|
||||||
|
@ -59,12 +54,6 @@ export const Edit = ( {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
const toggleAttribute = ( key: keyof Attributes ): void => {
|
|
||||||
const newAttributes = {} as Partial< Attributes >;
|
|
||||||
newAttributes[ key ] = ! ( attributes[ key ] as boolean );
|
|
||||||
setAttributes( newAttributes );
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<FormStepBlock
|
<FormStepBlock
|
||||||
attributes={ attributes }
|
attributes={ attributes }
|
||||||
|
@ -77,26 +66,24 @@ export const Edit = ( {
|
||||||
<InspectorControls>
|
<InspectorControls>
|
||||||
<PanelBody
|
<PanelBody
|
||||||
title={ __(
|
title={ __(
|
||||||
'Calculations',
|
'Shipping Calculations',
|
||||||
'woo-gutenberg-products-block'
|
'woo-gutenberg-products-block'
|
||||||
) }
|
) }
|
||||||
>
|
>
|
||||||
<ToggleControl
|
<p className="wc-block-checkout__controls-text">
|
||||||
label={ __(
|
{ __(
|
||||||
'Hide shipping costs until an address is entered',
|
'Options that control shipping can be managed in your store settings.',
|
||||||
'woo-gutenberg-products-block'
|
'woo-gutenberg-products-block'
|
||||||
) }
|
) }
|
||||||
checked={ attributes.shippingCostRequiresAddress }
|
</p>
|
||||||
onChange={ ( selected ) => {
|
<ExternalLink
|
||||||
updateAttributeInSiblingBlock(
|
href={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=shipping§ion=options` }
|
||||||
clientId,
|
>
|
||||||
'shippingCostRequiresAddress',
|
{ __(
|
||||||
selected,
|
'Manage shipping options',
|
||||||
'woocommerce/checkout-shipping-method-block'
|
'woo-gutenberg-products-block'
|
||||||
);
|
) }
|
||||||
toggleAttribute( 'shippingCostRequiresAddress' );
|
</ExternalLink>{ ' ' }
|
||||||
} }
|
|
||||||
/>
|
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
{ globalShippingMethods.length > 0 && (
|
{ globalShippingMethods.length > 0 && (
|
||||||
<PanelBody
|
<PanelBody
|
||||||
|
@ -133,11 +120,14 @@ export const Edit = ( {
|
||||||
) }
|
) }
|
||||||
{ activeShippingZones.length && (
|
{ activeShippingZones.length && (
|
||||||
<PanelBody
|
<PanelBody
|
||||||
title={ __( 'Zones', 'woo-gutenberg-products-block' ) }
|
title={ __(
|
||||||
|
'Shipping Zones',
|
||||||
|
'woo-gutenberg-products-block'
|
||||||
|
) }
|
||||||
>
|
>
|
||||||
<p className="wc-block-checkout__controls-text">
|
<p className="wc-block-checkout__controls-text">
|
||||||
{ __(
|
{ __(
|
||||||
'You currently have the following shipping zones active.',
|
'Shipping Zones can be made managed in your store settings.',
|
||||||
'woo-gutenberg-products-block'
|
'woo-gutenberg-products-block'
|
||||||
) }
|
) }
|
||||||
</p>
|
</p>
|
||||||
|
@ -151,24 +141,11 @@ export const Edit = ( {
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
} ) }
|
} ) }
|
||||||
<ExternalLink
|
|
||||||
href={ `${ ADMIN_URL }admin.php?page=wc-settings&tab=shipping` }
|
|
||||||
>
|
|
||||||
{ __(
|
|
||||||
'Manage shipping zones',
|
|
||||||
'woo-gutenberg-products-block'
|
|
||||||
) }
|
|
||||||
</ExternalLink>
|
|
||||||
</PanelBody>
|
</PanelBody>
|
||||||
) }
|
) }
|
||||||
</InspectorControls>
|
</InspectorControls>
|
||||||
<Noninteractive>
|
<Noninteractive>
|
||||||
<Block
|
<Block noShippingPlaceholder={ <NoShippingPlaceholder /> } />
|
||||||
noShippingPlaceholder={ <NoShippingPlaceholder /> }
|
|
||||||
shippingCostRequiresAddress={
|
|
||||||
attributes.shippingCostRequiresAddress
|
|
||||||
}
|
|
||||||
/>
|
|
||||||
</Noninteractive>
|
</Noninteractive>
|
||||||
<AdditionalFields block={ innerBlockAreas.SHIPPING_METHODS } />
|
<AdditionalFields block={ innerBlockAreas.SHIPPING_METHODS } />
|
||||||
</FormStepBlock>
|
</FormStepBlock>
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
+ .wc-block-editor-components-external-link-card {
|
+ .wc-block-editor-components-external-link-card {
|
||||||
margin-top: -($gap-large - $gap);
|
margin-top: -($gap-large - $gap);
|
||||||
}
|
}
|
||||||
|
&:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
.wc-block-editor-components-external-link-card__content {
|
.wc-block-editor-components-external-link-card__content {
|
||||||
flex: 1 1 0;
|
flex: 1 1 0;
|
||||||
padding-right: $gap;
|
padding-right: $gap;
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
{"title":"Checkout Block","pageContent":"<!-- wp:woocommerce/checkout -->\n<div class=\"wp-block-woocommerce-checkout wc-block-checkout is-loading\"><!-- wp:woocommerce/checkout-fields-block -->\n<div class=\"wp-block-woocommerce-checkout-fields-block\"><!-- wp:woocommerce/checkout-express-payment-block -->\n<div class=\"wp-block-woocommerce-checkout-express-payment-block\"></div>\n<!-- /wp:woocommerce/checkout-express-payment-block -->\n\n<!-- wp:woocommerce/checkout-contact-information-block -->\n<div class=\"wp-block-woocommerce-checkout-contact-information-block\"></div>\n<!-- /wp:woocommerce/checkout-contact-information-block -->\n\n<!-- wp:woocommerce/checkout-shipping-address-block -->\n<div class=\"wp-block-woocommerce-checkout-shipping-address-block\"></div>\n<!-- /wp:woocommerce/checkout-shipping-address-block -->\n\n<!-- wp:woocommerce/checkout-billing-address-block -->\n<div class=\"wp-block-woocommerce-checkout-billing-address-block\"></div>\n<!-- /wp:woocommerce/checkout-billing-address-block -->\n\n<!-- wp:woocommerce/checkout-shipping-methods-block {\"shippingCostRequiresAddress\":false} -->\n<div class=\"wp-block-woocommerce-checkout-shipping-methods-block\"></div>\n<!-- /wp:woocommerce/checkout-shipping-methods-block -->\n\n<!-- wp:woocommerce/checkout-payment-block -->\n<div class=\"wp-block-woocommerce-checkout-payment-block\"></div>\n<!-- /wp:woocommerce/checkout-payment-block -->\n\n<!-- wp:woocommerce/checkout-order-note-block -->\n<div class=\"wp-block-woocommerce-checkout-order-note-block\"></div>\n<!-- /wp:woocommerce/checkout-order-note-block -->\n\n<!-- wp:woocommerce/checkout-terms-block -->\n<div class=\"wp-block-woocommerce-checkout-terms-block\"></div>\n<!-- /wp:woocommerce/checkout-terms-block -->\n\n<!-- wp:woocommerce/checkout-actions-block -->\n<div class=\"wp-block-woocommerce-checkout-actions-block\"></div>\n<!-- /wp:woocommerce/checkout-actions-block --></div>\n<!-- /wp:woocommerce/checkout-fields-block -->\n\n<!-- wp:woocommerce/checkout-totals-block -->\n<div class=\"wp-block-woocommerce-checkout-totals-block\"><!-- wp:woocommerce/checkout-order-summary-block -->\n<div class=\"wp-block-woocommerce-checkout-order-summary-block\"></div>\n<!-- /wp:woocommerce/checkout-order-summary-block --></div>\n<!-- /wp:woocommerce/checkout-totals-block --></div>\n<!-- /wp:woocommerce/checkout -->"}
|
{"title":"Checkout Block","pageContent":"<!-- wp:woocommerce/checkout -->\n<div class=\"wp-block-woocommerce-checkout wc-block-checkout is-loading\"><!-- wp:woocommerce/checkout-fields-block -->\n<div class=\"wp-block-woocommerce-checkout-fields-block\"><!-- wp:woocommerce/checkout-express-payment-block -->\n<div class=\"wp-block-woocommerce-checkout-express-payment-block\"></div>\n<!-- /wp:woocommerce/checkout-express-payment-block -->\n\n<!-- wp:woocommerce/checkout-contact-information-block -->\n<div class=\"wp-block-woocommerce-checkout-contact-information-block\"></div>\n<!-- /wp:woocommerce/checkout-contact-information-block -->\n\n<!-- wp:woocommerce/checkout-shipping-address-block -->\n<div class=\"wp-block-woocommerce-checkout-shipping-address-block\"></div>\n<!-- /wp:woocommerce/checkout-shipping-address-block -->\n\n<!-- wp:woocommerce/checkout-billing-address-block -->\n<div class=\"wp-block-woocommerce-checkout-billing-address-block\"></div>\n<!-- /wp:woocommerce/checkout-billing-address-block -->\n\n<!-- wp:woocommerce/checkout-shipping-methods-block -->\n<div class=\"wp-block-woocommerce-checkout-shipping-methods-block\"></div>\n<!-- /wp:woocommerce/checkout-shipping-methods-block -->\n\n<!-- wp:woocommerce/checkout-payment-block -->\n<div class=\"wp-block-woocommerce-checkout-payment-block\"></div>\n<!-- /wp:woocommerce/checkout-payment-block -->\n\n<!-- wp:woocommerce/checkout-order-note-block -->\n<div class=\"wp-block-woocommerce-checkout-order-note-block\"></div>\n<!-- /wp:woocommerce/checkout-order-note-block -->\n\n<!-- wp:woocommerce/checkout-terms-block -->\n<div class=\"wp-block-woocommerce-checkout-terms-block\"></div>\n<!-- /wp:woocommerce/checkout-terms-block -->\n\n<!-- wp:woocommerce/checkout-actions-block -->\n<div class=\"wp-block-woocommerce-checkout-actions-block\"></div>\n<!-- /wp:woocommerce/checkout-actions-block --></div>\n<!-- /wp:woocommerce/checkout-fields-block -->\n\n<!-- wp:woocommerce/checkout-totals-block -->\n<div class=\"wp-block-woocommerce-checkout-totals-block\"><!-- wp:woocommerce/checkout-order-summary-block -->\n<div class=\"wp-block-woocommerce-checkout-order-summary-block\"></div>\n<!-- /wp:woocommerce/checkout-order-summary-block --></div>\n<!-- /wp:woocommerce/checkout-totals-block --></div>\n<!-- /wp:woocommerce/checkout -->"}
|
||||||
|
|
|
@ -143,7 +143,7 @@ test.describe( 'Merchant → Cart', () => {
|
||||||
await expect( filledCartAudioButton ).toBeHidden();
|
await expect( filledCartAudioButton ).toBeHidden();
|
||||||
} );
|
} );
|
||||||
|
|
||||||
test( 'shows empty cart when changing the view and allows toggling of shipping calculator', async ( {
|
test( 'shows empty cart when changing the view', async ( {
|
||||||
page,
|
page,
|
||||||
editor,
|
editor,
|
||||||
editorUtils,
|
editorUtils,
|
||||||
|
@ -188,24 +188,6 @@ test.describe( 'Merchant → Cart', () => {
|
||||||
' [data-type="woocommerce/empty-cart-block"]'
|
' [data-type="woocommerce/empty-cart-block"]'
|
||||||
)
|
)
|
||||||
).toBeHidden();
|
).toBeHidden();
|
||||||
|
|
||||||
await editor.selectBlocks(
|
|
||||||
await editorUtils.getBlockByName(
|
|
||||||
'woocommerce/cart-order-summary-shipping-block'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
await editor.openDocumentSettingsSidebar();
|
|
||||||
const shippingLabel = editorUtils.page.getByLabel(
|
|
||||||
'Shipping calculator'
|
|
||||||
);
|
|
||||||
await shippingLabel.check();
|
|
||||||
await expect(
|
|
||||||
editor.canvas.getByText( 'Change address' )
|
|
||||||
).toBeVisible();
|
|
||||||
await shippingLabel.uncheck();
|
|
||||||
await expect(
|
|
||||||
editor.canvas.getByText( 'Change address' )
|
|
||||||
).toBeHidden();
|
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
} );
|
} );
|
||||||
|
|
Loading…
Reference in New Issue