Woocommerce Categories - Add Custom Field At Bottom

Hi there - Our website uses Woocommerce 3.7, Theme X version 6.5. Cornerstone 4 and we have a custom child theme.

For product categories we want to add a field after the products/subcategories are listed. See image with area circled in red.

This field would allow us to enter text/html to further enhance the product category “pages”. For example, inserting technical information, instructions, video, etc…

I have done this with other Woocommerce sites I manage. But these sites do not use Theme X/Cornerstone.

I attempted to add the extra category field by using the Custom Field plugin which we already had installed. Specifically.

  1. Visited the Custom Field Plugin
  2. Added a Group Field with the following specifications
    Field Label - Category Field
    Field Name - category_field
    Field Type - Wysiwyg Editor
    Instructions - Enter HTML
    Required - No
    Default Value -
    Tabs - Visual & Text
    Toolbar - Full
    Show Media Upload Buttons - Yes
    Delay initialization? - No
    Conditional Logic - No
    Wrapper Attributes

Location
Rules -
Show this field group - Taxonomy - is equal to - Category (product_cat)

Settings
Active - Yes
Style - Seamless (no metabox)
Position - Normal (after content)
Label placement - Top aligned
Instruction placement - Below labels
Order No. 0
Decription
Hide on screen - all unchecked

I then went to a category in the admin, found the new field box and entered some random sentences. Updated and visited the category. The random sentences did not appear. I revisited the field in the Custom field plugin and changed the Field Type to Text area. Save and revisited the product category and the random sentences still did not appear. I also switched to the parent theme which would be Theme X. But that didnt allow the random sentences to appear on the product category either.

I realize this is customization, but would be interested in any insights you could share.

PS: Within a few days we are updating to the latest versions of Woo/ThemeX/Cornerstone, but I don’t think that will make a difference.

Thanks
Tim

Hello Tim,

Thank you for the very detailed post information. Please be advised that custom fields will not automatically display in pages or anywhere in the site. If you may have used the same plugin in the previous sites, it could be that the theme supports and integrates the plugin. Does the plugin provides a shortcode or a way to display the output? To better assist you with your issue, kindly provide us access to your site so that we can check your settings. Please create a secure note with the following info:
– Link to your site
– WordPress Admin username / password

To know how to create a secure note, please check this out: https://theme.co/apex/forum/t/how-to-get-support/288

Best Regards.

@RueNel - Secure note has been created. Thanks Tim

Hello Tim,

I went ahead and updated your Snippet into this:

function action_woocommerce_after_shop_loop() {
 
  $term_id = get_queried_object()->term_id;

  $post_id = 'product_cat_'.$term_id;

  $custom_field = get_field('category_field', $post_id); // My Advanced Custom Field Variable

  echo '<div style="clear: both;">' .  $custom_field . '</div>';
 
};
 
add_action( 'woocommerce_after_shop_loop', 'action_woocommerce_after_shop_loop', 10, 2 );

This “echo '<div style="clear: both;">' . $custom_field . '</div>';” should align the text content properly into your page.

Check your product archive now.

1 Like

@RueNel - Yes, that formatted it properly. Thank you. I have one related question. For Woocommerce categories, there are no editing capabilities within Theme X and Cornerstone, correct? Its not like a product page were we can add additional information via Cornerstone. I just want to make sure I understand how Theme X, Cornerstone and Woo interact when it comes to product categories.

Thanks
Tim

Hey Tim,

Yes that’s correct, WooCommerce category pages are not editable in Cornerstone. Similarly all archive pages are not editable within X theme or Cornerstone.

Cheers!

1 Like

@RueNel and @Nabeel - Thanks for the help

You are most welcome!

1 Like

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.