WooCommerce settings API set checkbox checked by default
Using WooCommerce settings API to create some options on its settings page: https://docs.woocommerce.com/document/adding-a-section-to-a-settings-tab/
Everything works fine but unfortunately, I can’t seem to get checkboxes to be checked by default (before admin actually saves changes…aka on fresh install)
I know I can create the option in the DB on plugin install but I’m trying to just get the checkbox checked by default without creating options on plugin activation.
I’ve tried multiple options
'name' => __( 'Field Name', 'lpac' ), 'desc' => __( 'Field description', 'lpac' ), 'id' => 'field_id', 'type' => 'checkbox', 'default' => true, // doesn't work 'css' => 'min-width:300px;', );
I’ve tried setting the default to different values like ‘checked’ and ‘on’ but still, the checkbox is not checked by default