Okay
  Public Ticket #3690046
Broken snippet code
Closed

Comments

  •  3
    Mounir started the conversation

    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 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 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);


    3054381350.png
  •  2,114
    WebWizards replied

    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:

    4181947390.png



    Please try to copy it with the 'Copy Code' button. Perhaps it's a problem with how it is copied:

    2526144918.png

    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