Untitled
plain_text
2 months ago
1.7 kB
4
Indexable
Never
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="code-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);