Devendra174's picture
Upload folder using huggingface_hub
1e92f2d verified

useSiteSettings

Simple React custom hook to handle site options.

API

const { get, save, update } = useSiteSettings( <site-id> );

countriesList

A countries list with payment context.

get()

Simple getter helper.

update(, )

Helper to 'update' site options in the redux store.

save(, )

Helper to 'save' site options permanently on the server-side.

Example

import useSiteSettings from './use-site-settings';

function StoreAddressFrom() {
    const { get, save, update } = useSiteSettings( 'site-id' );

    return (
        <div>
            <TextControl
                label={ __( 'Store address' ) }
                value={ get( 'woocommerce_store_address' ) }
                onChange={ ( newAddress ) => update( { woocommerce_store_address: newAddress } ) }
            />

            <Button onClick={ save }>Save</Button>
        </div>
    );
}