Hello Eva,
I want to attach some custom fields to Woocommerce products like the UPC code you need for amazon. this is what i put in the function.php file:
<?php
define(‘ETHEME_DOMAIN’, ‘legenda’);
require_once( get_template_directory() . ‘/framework/init.php’ );
add_action( ‘woocommerce_product_options_pricing’, ‘wc_rrp_product_field’ );
function wc_rrp_product_field() {
woocommerce_wp_text_input( array( ‘id’ => ‘UPC’, ‘class’ => ‘wc_input_price short’, ‘label’ => __( UPC, ‘woocommerce’ ) .’)’ ) );
}
add_action( ‘save_post’, ‘wc_rrp_save_product’ );
function wc_rrp_save_product( $product_id ) {
// If this is a auto save do nothing, we only save when update button is clicked
if ( defined( ‘DOING_AUTOSAVE’ ) && DOING_AUTOSAVE )
return;
if ( isset( $_POST[‘UPC’] ) ) {
if ( is_numeric( $_POST[‘UPC’] ) )
update_post_meta( $product_id, ‘UPC’, $_POST[‘UPC’] );
} else delete_post_meta( $product_id, ‘UPC’ );
}
Now this show up nicely, however when i try to import products from WP all import- the custom field UPC does not show up…
Do you have a code that other plugins would recognise as “a custom field” for products?
Many thanks for your reply!