Snippets

Visser Labs Adding multiple Custom Term Taxonomy to the Products export type

Created by Michael Visser

File functions.php Added

  • Ignore whitespace
  • Hide word diff
+<?php
+function custom_woo_ce_extend_product_fields( $fields ) {
+
+    $fields[] = array( 
+        'name' => 'fruit', 
+        'label' => __( 'Fruit', 'woo_ce' ), 
+        'hover' => __( 'Fruit within functions.php', 'woo_ce' ) 
+    ); 
+    $fields[] = array( 
+        'name' => 'vegetable', 
+        'label' => __( 'Vegetable', 'woo_ce' ), 
+        'hover' => __( 'Vegetable within functions.php', 'woo_ce' ) 
+    ); 
+    return $fields;
+
+} 
+add_filter( 'woo_ce_product_fields', 'custom_woo_ce_extend_product_fields' );
+
+function custom_woo_ce_extend_product_item( $product, $product_id ) {
+
+    $term_taxonomy = 'product-fruit'; 
+    $product->fruit = woo_ce_get_product_assoc_tags( $product_id, $term_taxonomy );
+
+    $term_taxonomy = 'product-vegetable'; 
+    $product->vegetable = woo_ce_get_product_assoc_tags( $product_id, $term_taxonomy );
+    return $product;
+
+} 
+add_filter( 'woo_ce_product_item', 'custom_woo_ce_extend_product_item', 10, 2 );
+?>
HTTPS SSH

You can clone a snippet to your computer for local editing. Learn more.