[[extensions.settings.fields]]
key = "showBranding"
type = "boolean"
name = "Show Branding"
default = true
“shopify app dev” command line doesn’t throw any errors about the default (unlike default_value, or some other key) key so it in theory accepts it, but setting it to true or 1 or “true” doesn’t seem to change anything in my App settings on the Thank you page, it still defaults itself to False.
This affects all my other fields as well, but this one is a priority for my customers.
I’d appreciate any advice or maybe if this is on a roadmap to be added, thanks.
We should code the extension so that it still works if the merchant hasn’t set a value for the setting. Please see the below example from shopify documentation.
Please refer the documentation:
import React from "react";
import {
reactExtension,
Banner,
useSettings,
} from "@shopify/ui-extensions-react/checkout";
// Set the entry points for the extension
const checkoutBlock = reactExtension("purchase.checkout.block.render", () => <App />);
export { checkoutBlock };
const deliveryAddress = reactExtension("purchase.checkout.delivery-address.render-before", () => <App />);
export { deliveryAddress };
function App() {
// Use the merchant-defined settings to retrieve the extension's content
const {title: merchantTitle, description, collapsible, status: merchantStatus} = useSettings();
// Set a default status for the banner if a merchant didn't configure the banner in the checkout editor
const status = merchantStatus ?? 'info';
const title = merchantTitle ?? 'Custom Banner';
// Render the banner
return (
<Banner title={title} status={status} collapsible={collapsible}>
{description}
</Banner>
);
}
Please see area:
// Set a default status for the banner if a merchant didn’t configure the banner in the checkout editor
const status = merchantStatus ?? ‘info’;
const title = merchantTitle ?? ‘Custom Banner’;
Yes, but we can code the extension to set default value, if the merchant hasn’t set a value for the setting. Like example mentioned on the documentation.
Yes, this works fine for text fields, but doesn’t work for boolean types, as they default to false and there’s no way to tell if the user chose false or it was defaulted on first install since there’s no undefined (null) state.