It works perfectly - showing a drop-down checkbox in the vendor dashboard.
The problem is it isn't saving these custom taxonomies to the related product. When they click "Save Product" it saves the category and featured image fine - but it doesn't save any custom taxonomies.
The custom taxonomies work fine in the back end though, it's just when they're saved through the edit-product page.
When adding code there to display custom fields such as custom taxonomies, it is sometimes (depending on the code) also needed to save the data, by hooking into MarketKing's hooks after saving the product.
Unfortunately it doesn't look like it will be that easy - when I try and save a product with that code in place it doesn't "save" at all - it just comes back with :
Thanks so much for looking into this further - Unfortunately I can't recreate this today for some reason. It still appears to not be saving the cross_curricular taxonomy to the backend. I have tried to recreate this with other custom taxonomies my site uses today as well and can't get it to work for them either (I have just tried duplicating the Code Snippet and changing the taxonomy though - there may be more to it).
Would you mind just check the backend again for me and seeing why it doesn't appear to be saving it anymore like you suggested yesterday?
That is annoying about the selected paramenter - are you saying that if I changed the drop down's to something else it would work straight away?
Thanks so much for your help - I know this is stretching the limits of customer service for this plugin but I really do appreciate the help :)
Hi there!
I have added a few custom taxonomies to the seller dashboard using the following code, added to the edit-product file :
<!-- CROSS CURRICULAR -->
<div class="col-xxl-3 col-md-6 marketking_card_gal_cat_tags">
<div class="code-block marketking_cattag_card">
<h6 class="overline-title title">
<?php esc_html_e('Does your resource include any cross curricular topics?','marketking-multivendor-marketplace-for-woocommerce');?>
</h6>
<div class="form-group">
<div class="form-control-wrap">
<?php
// Modify the arguments as needed for your custom taxonomy 'cross_curricular'
$cross_curricular_args = array(
'taxonomy' => 'cross_curricular',
'name' => 'marketking_select_cross_curricular[]', // Modify the name to allow multiple choices
'class' => 'form-select',
'orderby' => 'name',
'title_li' => '',
'multiple' => 'multiple', // Enable multiple choices
);
wp_dropdown_categories($cross_curricular_args);
?>
</div>
</div>
</div>
</div>
It works perfectly - showing a drop-down checkbox in the vendor dashboard.
The problem is it isn't saving these custom taxonomies to the related product. When they click "Save Product" it saves the category and featured image fine - but it doesn't save any custom taxonomies.
The custom taxonomies work fine in the back end though, it's just when they're saved through the edit-product page.
Thanks!
Hi Peter,
When adding code there to display custom fields such as custom taxonomies, it is sometimes (depending on the code) also needed to save the data, by hooking into MarketKing's hooks after saving the product.
Please try adding this PHP code to your site:
I think this may be able to do it, but if not it's just a matter of finding the right code to programmatically give those values to the product id.
Let me know if that can solve it for you,
Kind regards,
Stefan
Hi Stefan,
Unfortunately it doesn't look like it will be that easy - when I try and save a product with that code in place it doesn't "save" at all - it just comes back with :
bundle.js?ver=6.2.2:1 POST https://schoolsmusicmarket.com/wp-admin/admin-ajax.php 500
Error inside console.
Thanks,
Pete
Would it be possible to share a backend login to the site or a staging clone site with us?
I could look into it directly and try to get this working.
I got that to work by making a change to the snippet and to the edit-product.php template.
Now when I save the product, I can see the elements if I go to https://schoolsmusicmarket.com/wp-admin/post.php?post=232133&action=edit
The only problem is that the code you have on edit-product.php does not show the "selected" ones.
I think you either need to add the "selected" parameter and set it to an array of values ( see https://wordpress.stackexchange.com/questions/326424/wp-dropdown-categories-not-showing-option-as-selected ) or build the category dropdown in a different way.
Thanks so much for looking into this further - Unfortunately I can't recreate this today for some reason. It still appears to not be saving the cross_curricular taxonomy to the backend. I have tried to recreate this with other custom taxonomies my site uses today as well and can't get it to work for them either (I have just tried duplicating the Code Snippet and changing the taxonomy though - there may be more to it).
Would you mind just check the backend again for me and seeing why it doesn't appear to be saving it anymore like you suggested yesterday?
That is annoying about the selected paramenter - are you saying that if I changed the drop down's to something else it would work straight away?
Thanks so much for your help - I know this is stretching the limits of customer service for this plugin but I really do appreciate the help :)
Pete
I think I see where the issue is. If you check the HTML of the select dropdown:
You see that the name is marketking_select_cross_curricular[][] - however, it should be marketking_select_cross_curricular[]
(it should have [] only once to specify it's an array)
To fix it, I delete your [] in edit-product.php here:
It seems the dropdown function there adds it automatically so it's no longer needed.
After deleting [] from the name in edit-product.php I believe now it's working.
I enter
and in the backend I see:
Thanks so much! That worked, and I've managed to recreate it for all my other taxonomies in a snippet, so all is good!