I am using plugins called Advanced Custom Fields (ACF) and WooCommerce. I want to create a text and image field for WooCommerce product variation. I created fields in ACF and assigned them to "Post Type" > "product_variation"
.
But for I don’t see these fields under product > Variations
. I searched and it looks like I have to write a custom code to accommodate these fields. I tried searching the problem and most of the suggestions and tutorials I founds are about creating custom fields via code and not using ACF which is not helping me as the fields have to be using ACF and that is because I am using Visual Composer to pull these ACF fields on front end.
It’s not acf but you just have to add some code to your “function.php” of your child theme under /public_html/wp-content/themes/yourtheme-child/function.php.
Please have a look to this tutorial http://www.remicorson.com/mastering-woocommerce-products-custom-fields/
For instance, in my code I’ve added 2 fields for the RRP and another one for personal use (Price per Pair):
If you have any question please feel free to ask.
As far as I know the Advanced Custom Fields plugin only allows you to add custom fields for editors. These fields cannot be used to build the front-end
except by putting hands in the code.
If you want to add custom fields for your products (so the customers can do some personalization), you have to use another plugin. I personally use WC Fields Factory, it let you define additional data for your products, like size, color, image, etc. Just use the new Field Factory menu.
Of course there should be other ones I haven’t tried.
I faced this problem myself and given how frequently WooCommerce changes I was hesitant to shim some extra fields in with code. I did figure out a minimal code workaround which may or may not fit your needs.
Essentially it’s “proxying” the variation’s custom fields in a regular post and accessing those fields by putting that post ID in the product variation’s SKU field.
I started by setting up a post category “custom-fields” – which I hide via a redirect to the similarly named product.
I set up my custom fields for the post category: custom-fields and then I added a post e.g. “widget x red” and I input the custom fields for the red variation.
Once the post saved I added the post ID to the product variation SKU field.
Customizing the CSS I hid the SKU field and editing the child theme woocommerce/single-product.php I added a little PHP to retrieve the custom fields.
After which I had the custom fields indexed by variation ID