/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { createInterpolateElement, useState } from '@wordpress/element'; import { ADMIN_URL } from '@woocommerce/settings'; import { CHECKOUT_PAGE_ID } from '@woocommerce/block-settings'; import { CheckboxControl, SelectControl, TextControl, ExternalLink, Notice, } from '@wordpress/components'; import styled from '@emotion/styled'; /** * Internal dependencies */ import { SettingsCard, SettingsSection } from '../shared-components'; import { useSettingsContext } from './settings-context'; const GeneralSettingsDescription = () => ( <>

{ __( 'General', 'woo-gutenberg-products-block' ) }

{ __( 'Enable or disable local pickup on your store, and define costs. Local pickup is only available from the block checkout.', 'woo-gutenberg-products-block' ) }

{ __( 'View checkout page', 'woo-gutenberg-products-block' ) } ); const StyledNotice = styled( Notice )` margin-left: 0; margin-right: 0; `; const GeneralSettings = () => { const { settings, setSettingField, readOnlySettings } = useSettingsContext(); const [ showCosts, setShowCosts ] = useState( !! settings.cost ); return ( { readOnlySettings.hasLegacyPickup && ( { createInterpolateElement( __( 'Enabling this will produce duplicate options at checkout. Remove the local pickup shipping method from your shipping zones.', 'woo-gutenberg-products-block' ), { a: ( // eslint-disable-next-line jsx-a11y/anchor-has-content ), } ) } ) } { setShowCosts( ! showCosts ); setSettingField( 'cost' )( '' ); } } label={ __( 'Add a price for customers who choose local pickup', 'woo-gutenberg-products-block' ) } help={ __( 'By default, the local pickup shipping method is free.', 'woo-gutenberg-products-block' ) } /> { showCosts ? ( <> ) : null } ); }; export default GeneralSettings;