Skip Navigation

[Resolved] Need to add custom field values in Additional Info tab on a single product page

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 1 reply, has 2 voices.

Last updated by Christopher Amirian 3 years, 9 months ago.

Assisted by: Christopher Amirian.

Author
Posts
#2353497

Hi,
I have a Woocommerce site, with added custom field to Product
Field: produkta-pazinojumi
Field type: checkboxes

Each product can have a different checkbox selected, it is like additional info for a particular product.
What I would like to, is to display selected values on a single product page > Additional Info tab
Currently, it displays dimensions info.

What is the link to your site?
hidden link

#2353631

Christopher Amirian
Supporter

Languages: English (English )

Hi there,

You need to use Woocommerce hooks for that. A potential solution can be this:

hidden link

Also to retrieve a custom field you can use this method:

https://toolset.com/documentation/customizing-sites-using-php/functions/#checkboxes

add_filter( 'woocommerce_product_tabs', 'woo_rename_tabs', 98 );
function woo_rename_tabs( $tabs ) {
    global $product;
    $tabs['additional_information']['callback'] = 'chr_add_additional_information'; // this is the function name which is included below
    return $tabs;
}

function chr_add_additional_information(){
	woocommerce_product_additional_information_tab(); // This function calls  wc_get_template( 'single-product/tabs/additional-information.php' );
       echo ( types_render_field( "produkta-pazinojumi", array( "separator" => ", " ) ))
}

The echo ( types_render_field( "produkta-pazinojumi", array( "separator" => ", " ) )) portion of the code retrieves the checkboxes and separate the values with comma.

You can add the code as a custom file to Toolset using the method below:

https://toolset.com/documentation/programmer-reference/adding-custom-code/using-toolset-to-add-custom-code/

Finally please be aware of this errata as you want to retrieve checkboxes:

https://toolset.com/errata/checkboxes-that-save-0-are-interpreted-as-checked-by-views/

Kindly consider that the request is a custom development one and outside of our support scope. We did our best to give you the pointers to get started with the feature, but if you need additional help you'd better consider hiring a developer.

Thank you.