Admin Dashboard, Product Page

WooCommerce Custom Checkbox Field For The Product Editor

WooCommerce custom checkbox field for products when editing


There are no pre-requisites in order for you to be able to implement this solution.

How To Implement This Solution?

Simply copy the pre-coded solution to your active theme’s functions.php or preferably the Code Snippets Plugin.

About This Solution

This guide shows you how to create a custom checkbox field type in the product editor of WooCommerce. The Sold Individually field is an example checkbox field. A custom checkbox field allows your shop manager to define if a certain option is true or false. This guide also shows you how you can return the output of the checkbox whether it’s checked or unchecked.

 * Snippet Name:     WooCommerce Custom Product Checkbox Metabox
 * Snippet Author:

// Create the custom product metabox
add_action ('woocommerce_product_options_advanced', 'ecommercehints_custom_product_checkbox_metabox');
function ecommercehints_custom_product_checkbox_metabox() {
   echo '<div class="options_group">';
   woocommerce_wp_checkbox(array ( // A checkbox type field
      'id'                => 'custom_product_checkbox_metabox',
      'value'             => get_post_meta (get_the_ID(), 'custom_product_checkbox_metabox', true),
      'label'             => 'Custom Checkbox Label',
      'description'       => 'This is the description',
      'desc_tip'          => true // If true, place description in question mark tooltip.
   echo '</div>';

// Save data entered in the product metabox
add_action ('woocommerce_process_product_meta', 'ecommercehints_save_field_on_update', 10, 2);
function ecommercehints_save_field_on_update ($id, $post) {
      update_post_meta ($id, 'custom_product_checkbox_metabox', $_POST['custom_product_checkbox_metabox']);

How Do I Get The Custom Checkbox Field Data?

global $product;
$custom_product_checkbox_metabox = $product->get_meta ('custom_product_checkbox_metabox');
echo $custom_product_checkbox_metabox;

100 WooCommerce Conversion Rate Optimisation Tips

This field is for validation purposes and should be left unchanged.

Let’s collaborate!

Need to outsource WordPress development?

Join forces with UnlimitedWP for an outsourced white label web development service you can truly rely on.

First Timer Here?

Sign up to receive 20% off on your first month with us.