I added custom product_type_option like this

enter image description here

by filter product_type_option hook like this

function rpf_add_wild_card_product_type_option($type_options) {
    $checked = 'no';
    $type_options['wild_card'] = array(
        'id'            => '_wild_card',
        'wrapper_class' => 'show_if_simple',
        'label'         => __('Wild Card', 'woocommerce'),
        'description'   => __('Please check if this product is wild card', 'woocommerce'),
        'default'           => $checked,
    return $type_options;
add_filter('product_type_option', 'rpf_add_wild_card_product_type_option', 100, 1);

But, WooCommerce never save Wild Card Field!

I want WooCommerce treat my wild card product type option like Virtual,Downloadable Field.

What should I do in this case?

  • please edit your question to put the code directly instead of a picture. – mmm Jan 28 '18 at 11:11

Your code only creates the checkbox, you need also to save the value like that

add_filter("product_type_options", function ($product_type_options) {

    $product_type_options["wildcard"] = [
        "id"            => "_wildcard",
        "wrapper_class" => "show_if_simple",
        "label"         => "Wildcard",
        "description"   => "Description",
        "default"       => "no",

    return $product_type_options;


add_action("save_post_product", function ($post_ID, $product, $update) {

        , "_wildcard"
        , isset($_POST["_wildcard"]) ? "yes" : "no"

}, 10, 3);
  • I created bookable check box but when i check it and update it and edit again its not checked although the data is saved in database but i want to show a check-mark if it is checked or not. any help please. – DHL17 Mar 13 '18 at 11:14
  • I find it its default => 'yes'. any ways your answer helped me thanks. – DHL17 Mar 13 '18 at 11:19
  • @DHL17 - That's a false positive. The default value will check it unless you set the box to an unchecked status. The solution provided by 3M didn't work correctly for retrieving the stored value, so I'm looking for a solution, FedEx. I'll report back once I find one. – Rick Mac Gillis May 3 at 22:14
  • UPDATE: You must use the ID without the preceding _ as the key where you set the options. So $product_type_options["wildcard"] is very deliberate. WP is poorly designed... don't ask... Oh, and use woocommerce_update_product instead of save_post_product. – Rick Mac Gillis May 3 at 22:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.