product_type_options get saved value

Question

I have an issue with a product type option checkbox.
The value is saved correctly in the database.
If the value is yes the checkbox is unchecked.

The code that I wrote below

<?php
function add_octopus_child_option( $product_type_options ) {
    $product_type_options['_childocto'] = array(
        'id'            => '_childocto',
        'wrapper_class' => 'show_if_octopus',
        'label'         => __( 'Gekoppeld', 'woocommerce' ),
        'description'   => __( 'Vink dit aan indien dit niet het hoofdproduct is.', 'woocommerce' ),
    );
    return $product_type_options;
}
add_filter( 'product_type_options', 'add_octopus_child_option' );

function save_product_data_octopus($post_id){
    $woocommerce_checkbox = isset( $_POST['_childocto'] ) ? 'yes' : 'no';
    update_post_meta( $post_id, '_childocto', $woocommerce_checkbox );
}
add_action('save_post', 'save_product_data_octopus');
?>

Who can help me with this issue?

0
Ben 2 months 0 Answers 11 views 0

Leave an answer