Home Forums WC Vendors Pro Support 2 custom taxonomies not working

NOTICE: We've Moved to a Ticket System for Support

As of August 31, 2017 (12am EST) our support forums will be retired (read-only), and we will be moving to a support ticket system.  This will allow us to better organize and answer support requests, and provide a more personalized experience as we assist our customers.

For the time being, we will leave our forums open for reading and learning while we work on creating a more robust Knowledge Base for everyone to use.

If you are a WC Vendors Pro customer please open a support ticket here. 

If you are a WC Vendors user please open a support ticket on the Wordpress.org forums.

The information on this forum is outdated and in most instances no longer relevant. Please be sure to check our documentation for the most up to date information.

https://docs.wcvendors.com/

Thank you to all of our customers!

 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #67564
    Arjan Ros
    Participant

    Hi there!

    I’m trying to add a second custom taxonomy to the product-edit.php and the functions.php in my theme.

    I got this code working:

    // This code goes in your theme's functions.php 
    function form_conditie( $object_id ) { 
     WCVendors_Pro_Form_helper::select2( array(
    			'post_id'			=> $object_id,
    			'id'				=> 'wcv_custom_product_conditie[]',
    			'class'				=> 'select2',
    			'label'				=> __('Conditie', 'wcvendors-pro'),
    			'show_option_none'	=> __('Selecteer een conditie', 'wcvendors-pro'),
    			'taxonomy'			=>	'conditie', 
    			'taxonomy_args'		=> array( 
    									'hide_empty'	=> 0, 
    								), 	
    			'custom_attributes'	=> array( 'multiple' => 'multiple' ), 
    			)
    	); 
    }
    function save_conditie( $post_id ){ 
    	$term = $_POST[ 'wcv_custom_product_conditie' ]; 
    	$terms = implode(',', $term ); 
    	wp_set_post_terms( $post_id, $term, 'conditie' ); 
    }
    add_action( 'wcv_save_product', 'save_conditie' );

    And this in the product-edit.php

    ` <!– product Conditie –>
    <?php form_conditie( $object_id ); ?>`

    But when I add a second taxonomy, with the same code and replace the word ‘conditie’ with the name ‘maat’ .. I get an error 500.

    Both the taxonomies are registered in the backend.

    What am I doing wrong?

    #67601
    Anna
    Member

    Hello,
    I am not sure– did you perhaps miss changing one of the instances of the word conditie with maat?
    Also, a 500 error will usually show an error in your error_log, so check that for more information.

    #67908
    Arjan Ros
    Participant

    Hi Anna!

    You were right. I missed one of the instances.. thanks

    Now I’m dealing with another issue.

    When I select a term, like ‘brand new’ in the custom ‘Condition’ taxonomy in the Edit product page, or ‘size 32’ in the ‘Size’ taxonomy field.. the term is saved as a Number.

    So.. ‘brand new’ is saved and displayed as ‘207’ for example. Another strange thing is that these terms just get added to the list while I have defined standard terms for the Condition taxonomy such as ‘brand new’, ‘used’, etc.

    I want users to make a selection out of the available terms.

    When I look in the admin section, under Products and the list of terms under the Condition taxonomy, I can see 207, 268, etc, etc. have just been added to the taxonomy term list.

    Is this maybe something that isn’t right with the settings of the CPT UI plugin I used maybe?

    #67954
    Scott Lengacher
    Participant

    Arjan, it is likely that those numbers are actually the term IDs for those taxonomy values. I suggest you check. That is the issue I’m now facing.

    #68043
    Anna
    Member

    @arjanhague
    I shared this with Scott @scott also in another post.. this maybe of help to you.
    Essentially taking out the taxonomy formatting..
    Working with Custom Taxonomies in the front end forms in Pro is tricky.
    Perhaps this could be of help to you– Using the following format I was able to add “product condition” in a drop-down on the product add/edit form.

    The first part of the code should be placed within one of the DIV on the product-edit.php template, as instructed.
    ( Just in case you’ve not modified templates.. though I am guess you have! : https://www.wcvendors.com/kb/changing-vendor-templates/ )

    The second part of the code will go within your theme/child theme functions.php.

    https://gist.github.com/fervous/048b04a4a73cde43fd77b34405917f54

    You may be able to use this and modify it to suit your needs.. let me know.
    I am not 100% certain why the other method you have used is not properly saving.

    #68063
    Arjan Ros
    Participant

    Thank you Anna and Scott!

    Firstly, before I test this code..

    I choose custom taxonomies because there’s a Woocommerce filter widget plugin in the shop, that allows filtering on custom taxonomies so that user can filter on condition, or size.

    I’m not sure if that will will be possible with this code?

    #68110
    Anna
    Member

    @arjanhague
    Hello,
    No -this code will not actually register a taxonomy. SO it would not be searchable by those terms unless you made custom taxonomies somehow.
    This is really more of a workaround so that you CAN have their fields for the vendors to enter and for the customers to view; however.. not taxonomies that are searchable.
    I am just not sure why the custom taxonomy fields are not working properly, and this was my attempt to provide a work-around in the meantime.

    For searchable / filterable — you could also use attributes. There are filters available and advanced search plugins that work with attributes. Admin needs to create the attributes, but you can allow Vendors to add attribute terms: wp admin > woocommerce > wc vendors > product form: Allow vendors to add attribute terms. ( This does not allow vendors to add attributes )

    #68128
    Arjan Ros
    Participant

    I used the attributes before, and they are indeed filterable.

    The reason we switched to taxonomies is that the way users had to add attributes was too user-unfriendly. It showed during user testing.

    If there is a way to create a dropdown field like the categories, but filled with attributes? That would be great.

    #68158
    Anna
    Member

    Hello,
    Ok- Jamie is checking on the taxonomies; I am not sure what he will report, but you can follow this thread here:

    #68180
    Arjan Ros
    Participant

    Thank you. I will follow the thread you mentioned.

Viewing 10 posts - 1 through 10 (of 10 total)
  • The forum ‘WC Vendors Pro Support’ is closed to new topics and replies.