/** * External dependencies */ import { __ } from '@wordpress/i18n'; import { createInterpolateElement, useState } from '@wordpress/element'; import { ADMIN_URL, getSetting } 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 ); const shippingCostRequiresAddress = getSetting< boolean >( 'shippingCostRequiresAddress', false ); 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 ), } ) } ) } { __( 'When enabled, local pickup will appear as an option on the block based checkout.', 'woo-gutenberg-products-block' ) } { shippingCostRequiresAddress ? ( <>
{ __( 'If local pickup is enabled, the "Hide shipping costs until an address is entered" setting will be ignored.', 'woo-gutenberg-products-block' ) } ) : null } } /> ) => { event.target.setCustomValidity( __( 'Local pickup title is required', 'woo-gutenberg-products-block' ) ); } } onInput={ ( event: React.ChangeEvent< HTMLInputElement > ) => { event.target.setCustomValidity( '' ); } } /> { 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;