I have modified your code please check the below code.
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' ),
'default' => 'no'
);
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( 'woocommerce_process_product_meta_simple','save_product_data_octopus' );
add_action( 'woocommerce_process_product_meta_variable', 'save_product_data_octopus' );
Try with the above code and if does not work let me know.
Related Posts:
- Use wc_enqueue_js only on specific pages – nested add_action
- woocommerce subscriptions – get expiration date [closed]
- Automated Cart Update With Alert Box Each Time
- WooCommerce/WordPress: how hide entire table form after submit (Admin Dashboard)?
- How to auto fetch customer details in Woocommerce in checkout page
- I want to add custom add to cart link [closed]
- Extend Woocommerce Widget Class – WC_Widget_Product_Categories
- Change product_base programmatically
- Can a plugin redirect product page based on IF condition?
- WordPress WP_Query without query GET parameters
- Where to copy woocommerce files to in my custom theme to avoid editing the core plugin?
- custom post type with role Vendor
- Woocommerce custom Plugin in wordpress [closed]
- Add a custom WooCommerce settings tab with sections
- Payment field disappears on custom Paypal plugin
- I am having errors with checkout on wordpress
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- Looping through and combining calls to Woocommerce REST API
- How to import woocommerce custom fields data into another site?
- How do I remove an action hook inside a class that is called by another class?
- How keep woocommerce users separeted in multisite install and keep admins on network
- Custom field fetch error on woocommerce pdf invoice
- Woocommerce Convert existing order to the cart
- How to check if a plugin (WooCommerce) is active?
- How to get Woocommerce order product info
- I can’t fetch query parameters ($_GET parameters) with get_query_var
- Change Password Hint
- Woocommerce auto cancel On-Hold after X days
- Prevent multiple counts by same user – WP PostViews plugin
- The values of custom fields are not available functions.php
- Second select list values are not saved after clicking update
- Custom Shipping method not showing in checkout
- Why WordPress architecture is not pure object oriented and it don’t use MVC pattern? [closed]
- Use is_product_category() properly
- How can i display post loop in table format?
- PHP can I add line numbers to file_get_contents()
- Changing Woocommerce flat rate every nth number of items
- How to select WooCommerce products by post_meta and order them
- write custom woocommerce templates and forms
- Issue adding sub category programmatically
- what is the best practice to add new field to an api route
- How do I programmatically set a user as spam in BuddyPress? [closed]
- Which field should I edit to make the checkbox marked by default?
- Can’t print Yoast meta description into page template (syntax error, unexpected ‘.’) [closed]
- Add post with approval by the admin
- Using data sent via AJAX in multiple functions on a WP plugin
- Woocommerce display one random product via php
- customize woocommerce templates and display store on home
- Plugin development and composer
- WC_Customer delete function returns error
- Exclude product attributes from taxonomy terms loop
- WP All Import / Update stock quantity from multiple XML files
- Woocommerce: remove total sum from new order’s email [closed]
- Set default Database Storage Engine when creating tables with plugins?
- Alter Woocommerce product archive structure
- WooCommerce: Display product categories to make IF statement
- Execute Jquery when a specific page in my plugin is loading
- Ajax on the Administration Side of plugin – wp_localize_script – how to pass value from JQuery to PHP function in class?
- Replace category title with category description in woocommerce
- Add Custom Category Description When Empty
- I am having issue in divi woocomerce checkout module. (DIVI theme)
- Woocommerce display orders with products from specific categories to specific admins
- Display div if category has a specific parent
- Only the first image uploads
- How can I change the background color of divs dynamically (depending on an order-status in woocommerce)?
- How to get content on a blank basket/cart page in a custom theme with woocommerce
- Submit remote form to wordpress REST API and save data to custom post type
- Foreach Loop Of Post Types With Nested If Else If Not Completing Process
- WooCommerce REST API AJAX Auth – 401 response
- In a foreach loop, how can I add a meta value if it doesn’t exist?
- How to access this jQuery/AJAX data in a PHP file/WordPress plugin
- Woocommerce – if selected attribute term equals
- split 1 cart item into instock and back ordered
- post_exists stops working in a scheduled event
- register dependency css and js inside a plugin class
- When I create a new custom post type, it replaces the old post type
- Adding a widget under an ‘Add to Cart’ button through a PHP snippet
- Woocommerce Related Product by 2 taxonomy
- Hide price excluding tax when price is empty
- Add .php to end of all WordPress Pages (multisite)
- PHP get_category() function redeclared
- Woocommerce variation with radio button + price
- Display text of price (minus 20%) on every product page in a sentence.
- Getting Member Data From WhishList Member on Register
- I’m writing my first plugin and my echo output is showing up on every page of my wordpress installation
- Getting the date_diff function return the difference in days
- Save data of select list after clicking save
- Create and update Custom Cookie based on multiple GET and POST Values for first time visitors?
- Can’t remove menu items added by plugin
- Issues separating my Plugin pages into different files
- FATAL ERROR , Sommerce Theme [closed]
- Woocommerce linking variations
- Import js variables loaded via wp_localize_script() into js module without global scope connection
- Custom taxonomy with page post type – WordPress
- Too few arguments at registering new templates in my plugin
- Remove Woocommerce product from cart with ajax/fetch
- Automatically change insurance quantity based on cart total [closed]
- I want to lists posts in wordpress to nearest location entered by the user
- Why does WordPress not send the user the email to add a password?
- Hide ‘Downloadable’ and ‘Virtual’ checkbox options from Woocommerce Variations?