Support » Plugin: WooCommerce » Adding Custom Field to Additional Information

  • Resolved darrennicholson

    (@darrennicholson)


    Hi Folks,

    I’ve created a custom field on woocommerce using functions and got it displaying on the front end via a hook. However I’m wanting this field to be added to additional information tab for the products.

    Anyone have a fix/solution for this?

Viewing 9 replies - 1 through 9 (of 9 total)
  • Hi there,

    Can you please confirm us if the custom field that you want to add to your product page is a field that your customers need to fill or if it’s just some text that you want to display there?

    If it’s just a text, I’d suggest you to check this article to learn how to create a new product tab and add some content there: https://welaunch.io/en/2018/11/custom-woocommerce-product-tabs/

    If you want an easier approach, you can also use the WooCommerce Tab Manager plugin to add custom tabs and informative fields there.

    On the other hand, if you want to add a custom field that your customers need to use to add more details to the product when purchasing it (like adding a message to the product), the approach will be more complicated, as, apart from displaying this field, you’ll also need to add the required functionality to add it to the customer session when they add the product to the cart and to the order once it is generated (and you’ll probably want to display it on the backend too in the order editor page).

    The easiest way to achieve all of this would be to use a plugin like Product Add-ons.

    If you want to add these fields programmatically, I suggest you to take a look at articles like this one to get started.

    Thanks,

    Thread Starter darrennicholson

    (@darrennicholson)

    Hi @bernattorras,

    The custom field is something we would fill out in the back end say for a barcode and we want to publish this in the additional information tab table. Tried to hook on to you but sadly doesn’t seem possible.

    Hi @darrennicholson,

    I’m still a bit confused about where exactly you want to add and show this field..

    Do you mean that you’d like to add these custom fields (a barcode image for example) in your products from the backend and display it in a specific tab on the product page?

    If that’s the case, I’d suggest you to try “WooCommerce Tab Manager” plugin. With this plugin you’ll be able to add new tabs to your product page and add the content of the fields that you specify from the backend while creating the product (an image field for the barcode for example).

    Please give it a try and let us know if that’s what you’re looking for. If you’re looking for a different workflow, please provide us more details (and an example if possible) of where these fields should be located.

    Thanks!

    Thread Starter darrennicholson

    (@darrennicholson)

    No not looking to add another tab or image. When we add dimensions or weights to the product attributes in woocommerce it populates in the Additional Information tab. I’m looking to add another row to the table to show the barcode number in the same style as the product meta… i.e in the table.

    Thanks,

    Hey @darrennicholson,

    Thanks for the further explanation. There are a couple of ways you could go about this. It is possible to load content below the table via a hook. Here’s a function that would do that:

    
    function ijab_wc_insert_additional_information() {
        // load custom field here.
    }
    add_action( 'woocommerce_product_additional_information', 'ijab_wc_insert_additional_information' );
    

    That would still be in the additional information tab but under the table itself. There isn’t a hook to place the content into the table.

    below table

    To place the barcode inside the table, you can use a template override. You would need to copy the /templates/single-product/product-attributes.php file into your theme/child theme at /woocommerce/single-product/product-attributes.php. Then you can edit the table there to include a new row for your barcode.

    If you have any questions, let us know.

    Cheers

    Plugin Support EtienneP a11n

    (@etiennep)

    We haven’t heard back from you in a while, so I’m going to mark this as resolved – if you have any further questions, you can start a new thread.

    Hi @3sonsdevelopment – I’ve been trying to do something similar to @darrennicholson, I have an advanced custom field in the product variation that I want to display in the additional information table in a new row under dimensions and one of my other attributes as per this guide article: https://businessbloomer.com/woocommerce-add-custom-field-product-variation/. I’ve managed to successfully create a new row in the product-attributes.php file – but now I am not sure how to pull in my custom field value to display in that table. Any suggestions?

    To add custom field in additionnal information table you can use woocommerce_display_product_attributes filter

    function yourprefix_woocommerce_display_product_attributes($product_attributes, $product){
    	$product_attributes['customfield'] = [
    		'label'	=> __('custom', 'text-domain'),
    		'value' => get_post_meta($product->get_ID(), 'customfield', true),
    	];
    	return $product_attributes;
    }
    add_filter('woocommerce_display_product_attributes', 'yourprefix_woocommerce_display_product_attributes', 10, 2);
    • This reply was modified 3 years, 10 months ago by zecka1213.
    OC WordPress Web Designer

    (@oc-wordpress-web-designer)

    How would I add a variation custom field made from https://iconicwp.com/products/woocommerce-custom-fields-variations/ to the additional information table with a field id of: applications?

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Adding Custom Field to Additional Information’ is closed to new replies.