Comments 3Mounir started the conversationJuly 20, 2024 at 9:35pmHi this snippet code from page https://woocommerce-multivendor.com/docs/add-a-custom-taxonomy-to-vendor-products/ Step 2: Add the taxonomy to the vendor dashboard is Not working add_action('marketking_edit_product_after_tags', function($post){if (isset($post->ID)){?> <div class="row"> <div class="col-xxl-3 col-md-6 marketking_card_gal_cat_tags"> <div class="->span class="hljs-title">block marketking_cattag_card"> <h6 class="overline-title title"> <?php esc_html_e('Brands','marketking-multivendor-marketplace-for-woocommerce');?> </h6> <div class="form-group"> <div class="form-control-wrap"> <?php $selected_brands = wp_get_object_terms($post->ID, 'brand', array('fields' => 'ids', 'hide_empty' => false)); $brand_args = array( 'taxonomy' => 'brand', 'name' => 'marketking_select_brand', 'class' => 'form-select', 'orderby' => 'name', 'title_li' => '', 'multiple' => 'multiple', 'hide_empty' => false, 'selected' => implode(',',$selected_brands), );wp_dropdown_categories($brand_args); ?> </div> </div> </div> </div> </div> <?php }}, 10, 1); // save taxonomyadd_action('marketking_after_save_product', function($product_id, $vendor_id){ // Save "brand" taxonomy $brand_values = isset($_POST['marketking_select_brand']) ? $_POST['marketking_select_brand'] : array(); foreach ($brand_values as $index => $val){ $brand_values[$index] = intval($val); // transform to INT } wp_set_object_terms( $product_id, $brand_values, 'brand' ); }, 10, 2); 2,114WebWizards repliedJuly 21, 2024 at 8:53amHello Mounir,I tested that code now on my test site but I am not able to see that error.In my test I added it to functions.php as follows:Please try to copy it with the 'Copy Code' button. Perhaps it's a problem with how it is copied:If that still doesn't work I would suggest to check what the actual error is with a debug log: https://wordpress.org/plugins/debug-log-config-tool/I can also check directly if you'd like to share access to the site / staging site.Kind regards,Stefan Sign in to reply ...
Hi this snippet code from page https://woocommerce-multivendor.com/docs/add-a-custom-taxonomy-to-vendor-products/
Step 2: Add the taxonomy to the vendor dashboardis Not working
add_action('marketking_edit_product_after_tags', function($post){
if (isset($post->ID)){
?>
<div class="row">
<div class="col-xxl-3 col-md-6 marketking_card_gal_cat_tags">
<div class="->span class="hljs-title">block marketking_cattag_card">
<h6 class="overline-title title">
<?php esc_html_e('Brands','marketking-multivendor-marketplace-for-woocommerce');?>
</h6>
<div class="form-group">
<div class="form-control-wrap">
<?php
$selected_brands = wp_get_object_terms($post->ID, 'brand', array('fields' => 'ids', 'hide_empty' => false));
$brand_args = array(
'taxonomy' => 'brand',
'name' => 'marketking_select_brand',
'class' => 'form-select',
'orderby' => 'name',
'title_li' => '',
'multiple' => 'multiple',
'hide_empty' => false,
'selected' => implode(',',$selected_brands),
);
wp_dropdown_categories($brand_args);
?>
</div>
</div>
</div>
</div>
</div>
<?php
}
}, 10, 1);
// save taxonomy
add_action('marketking_after_save_product', function($product_id, $vendor_id){ // Save "brand" taxonomy $brand_values = isset($_POST['marketking_select_brand']) ? $_POST['marketking_select_brand'] : array(); foreach ($brand_values as $index => $val){ $brand_values[$index] = intval($val); // transform to INT } wp_set_object_terms( $product_id, $brand_values, 'brand' );
}, 10, 2);
Hello Mounir,
I tested that code now on my test site but I am not able to see that error.
In my test I added it to functions.php as follows:
Please try to copy it with the 'Copy Code' button. Perhaps it's a problem with how it is copied:
If that still doesn't work I would suggest to check what the actual error is with a debug log: https://wordpress.org/plugins/debug-log-config-tool/
I can also check directly if you'd like to share access to the site / staging site.
Kind regards,
Stefan