I read over the docs, but, I can't get it to work.
First of all, I have WordPress 5.8 and I installed the latest WooCommerce and I installed Metabox from the WordPress plugins directory and I installed MB Custom Table.
So, I already created a table with 7 columns with phpmyadmin.
One of the columns is ID, it's unsigned and does not allow nulls.
Now, I don't understand what to do next.
I saw the php file in your docs:
add_filter( 'rwmb_meta_boxes', 'your_prefix_register_meta_boxes' );
function your_prefix_register_meta_boxes( $meta_boxes ) {
$meta_boxes[] = array(
'title' => 'Meta Box Title',
'storage_type' => 'custom_table', // Important
'table' => 'my_custom_table', // Your custom table name
'fields' => array(
array(
'id' => 'address',
'type' => 'text',
'name' => 'Address',
),
array(
'id' => 'phone',
'type' => 'text',
'name' => 'Phone',
),
array(
'id' => 'email',
'type' => 'email',
'name' => 'Email',
),
),
);
return $meta_boxes;
}
I changed my_custom_table to my table name.
I changed the 'id' to match the column names in my custom table. And then I changed the types and names accordingly.
Do I need to change 'your_prefix_register_meta_boxes'?
Then, where do I put this code? Is it a new file? I think in the video you just put it in a file called test.php in the mu-plugins directory. Is that all I have to do?
I did that and when I went to my site (front end), it displayed the code on the site.
Then, I tried adding it to my functions.php file in the child theme directory and I deleted the file from the mu-plugins directory. The code doesn't display on the front end anymore, but, nothing happens either when I edit a product.
BTW, I want to add and save custom fields for my WooCommerce Products. So, please let me know if this even works for that.
Thanks.