/** * External dependencies */ import { __ } from '@wordpress/i18n'; import FeedbackPrompt from '@woocommerce/block-components/feedback-prompt'; import { InspectorControls } from '@wordpress/block-editor'; import { PanelBody, ToggleControl, CheckboxControl, Notice, Disabled, } from '@wordpress/components'; import BlockErrorBoundary from '@woocommerce/base-components/block-error-boundary'; import { PRIVACY_URL, TERMS_URL, CHECKOUT_PAGE_ID, } from '@woocommerce/block-settings'; import { getAdminLink } from '@woocommerce/settings'; import { __experimentalCreateInterpolateElement } from 'wordpress-element'; import { useRef } from '@wordpress/element'; import { EditorProvider, useEditorContext } from '@woocommerce/base-context'; import PageSelector from '@woocommerce/block-components/page-selector'; import { previewCart, previewSavedPaymentMethods, checkoutBlockPreview, } from '@woocommerce/resource-previews'; /** * Internal dependencies */ import Block from './block.js'; import './editor.scss'; const BlockSettings = ( { attributes, setAttributes } ) => { const { showCompanyField, showApartmentField, showPhoneField, requireCompanyField, requirePhoneField, showPolicyLinks, showReturnToCart, cartPageId, } = attributes; const { currentPostId } = useEditorContext(); const { current: savedCartPageId } = useRef( cartPageId ); return ( { currentPostId !== CHECKOUT_PAGE_ID && ( { __experimentalCreateInterpolateElement( __( 'If you would like to use this block as your default checkout you must update your page settings in WooCommerce.', 'woo-gutenberg-products-block' ), { a: ( // eslint-disable-next-line jsx-a11y/anchor-has-content ), } ) } ) } { __( 'Choose whether your checkout form requires extra information from customers.', 'woo-gutenberg-products-block' ) } setAttributes( { showCompanyField: ! showCompanyField, } ) } /> { showCompanyField && ( setAttributes( { requireCompanyField: ! requireCompanyField, } ) } className="components-base-control--nested" /> ) } setAttributes( { showApartmentField: ! showApartmentField, } ) } /> setAttributes( { showPhoneField: ! showPhoneField, } ) } /> { showPhoneField && ( setAttributes( { requirePhoneField: ! requirePhoneField, } ) } className="components-base-control--nested" /> ) } { __( 'Choose additional content to display.', 'woo-gutenberg-products-block' ) } setAttributes( { showPolicyLinks: ! showPolicyLinks, } ) } /> { showPolicyLinks && ( ! PRIVACY_URL || ! TERMS_URL ) && ( { __experimentalCreateInterpolateElement( __( 'Pages must be first setup in store settings: Privacy policy, Terms and conditions.', 'woo-gutenberg-products-block' ), { a1: ( // eslint-disable-next-line jsx-a11y/anchor-has-content ), a2: ( // eslint-disable-next-line jsx-a11y/anchor-has-content ), } ) } ) } setAttributes( { showReturnToCart: ! showReturnToCart, } ) } /> { showReturnToCart && ! ( currentPostId === CHECKOUT_PAGE_ID && savedCartPageId === 0 ) && ( setAttributes( { cartPageId: id } ) } labels={ { title: __( 'Return to Cart button', 'woo-gutenberg-products-block' ), default: __( 'WooCommerce Cart Page', 'woo-gutenberg-products-block' ), } } /> ) } ); }; const CheckoutEditor = ( { attributes, setAttributes } ) => { const { className, isPreview } = attributes; if ( isPreview ) { return checkoutBlockPreview; } return ( ); }; export default CheckoutEditor;
{ __( 'Choose whether your checkout form requires extra information from customers.', 'woo-gutenberg-products-block' ) }
{ __( 'Choose additional content to display.', 'woo-gutenberg-products-block' ) }