Hi Yes sorry I only put up part of the code. As I thought this woudl be enough. I’ve checked the data base files and they show that _gtin is the field title for the EAN codes. The database also shows the field for the brands as _berocket_brands but when I enter this in your variables it does not show.
Here is the full GTIN code from the functions.php file:-
/**
* Adding Custom GTIN Meta Field
* Save meta data to DB
*/
// add GTIN input field
add_action(‘woocommerce_product_options_inventory_product_data’,’woocom_simple_product_gtin_field’, 10, 1 );
function woocom_simple_product_gtin_field(){
global $woocommerce, $post;
$product = new WC_Product(get_the_ID());
echo ‘<div id=”gtin_attr” class=”options_group”>’;
//add GTIN field for simple product
woocommerce_wp_text_input(
array(
‘id’ => ‘_gtin’,
‘label’ => ‘GTIN’,
‘desc_tip’ => ‘true’,
‘description’ => ‘Enter the Global Trade Item Number (UPC,EAN,ISBN)’)
);
echo ‘</div>’;
}
// save simple product GTIN
add_action(‘woocommerce_process_product_meta’,’woocom_simple_product_gtin_save’);
function woocom_simple_product_gtin_save($post_id){
$gtin_post = $_POST[‘_gtin’];
// save the gtin
if(isset($gtin_post)){
update_post_meta($post_id,’_gtin’, esc_attr($gtin_post));
}
// remove if GTIN meta is empty
$gtin_data = get_post_meta($post_id,’_gtin’, true);
if (empty($gtin_data)){
delete_post_meta($post_id,’_gtin’, ”);
}
}
The meta key _gtin is being stored in the postsmeta table, as is the meta key _yoast_wpseo_primary_berocket_brand, if that is any help? ??
I’ve also done a search in the database for the terms gtin and brands and the main entries for both appear to be in the postsmeta table.
I’m probably just getting myself lost now!!
Cheers
Steve