Save and display product selected custom data everywhere in WooCommerce

后端 未结 2 1109
栀梦
栀梦 2020-12-21 17:07

I have a code that shows the checkbox on the product edit page. When I click on this checkbox, a select box is displayed on the single product page.

Here is my code:

2条回答
  •  甜味超标
    2020-12-21 17:57

    Your checkbox value is stored to database, try to change this code

    $roast_checkbox = isset( $_POST['_roast_checkbox'] ) ? 'yes' : 'no';
    

    with

    if ( isset( $_POST['_roast_checkbox'] ) {
    $roast_checkbox = $_POST['_roast_checkbox'];
    //update_post_meta
    }
    

提交回复
热议问题