• Resolved captainmitch

    (@captainmitch)


    Woocommerce Product Vendors creates new roles and capabilities. When a vendor admin or vendor manager is logged into the site and editing a products, they do not have access to the “resources” tab of the product page.

    If you click that tab, the tab is blank. I want to restrict the cost tab in the exact same way.

    When wordpress outputs the Vendor’s wp-admin/product-page, where does it decide, based on role, not to output the resources tab content? If I can find this, I can apply the same condition to the costs tab, yes?

    Alternatively, is there a “Capability” like “edit_product_cost” that I can assign via a custom function?

    The Woocommerce Product Vendors plugins defines roles and capabilities as follows:

    protected function default_admin_vendor_caps() { return apply_filters( ‘wcpv_default_admin_vendor_role_caps’, array( ‘read_product’ => true, ‘manage_product’ => true, ‘edit_products’ => true, ‘edit_product’ => true, ‘edit_published_products’ => true, ‘edit_shop_orders’ => true, ‘assign_product_terms’ => true, ‘upload_files’ => true, ‘read’ => true, ‘manage_bookings’ => true, ‘edit_others_products’ => true, ‘view_vendor_sales_widget’ => true, ‘delete_published_products’ => true, ‘delete_others_products’ => true, ‘delete_posts’ => true, ‘delete_others_posts’ => true, ‘edit_comment’ => false, ‘edit_comments’ => false, ‘view_woocommerce_reports’ => false, ‘publish_products’ => false, ) ); }

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Hannah S.L.

    (@fernashes)

    Automattic Happiness Engineer

    Hey there!

    If you have a valid license for WooCommerce Product Vendors, you’re welcome to create a ticket here:
    https://woocommerce.com/my-account/create-a-ticket/

    Please do explain which resource tab you’re looking at – a screenshot would be great!

    Thread Starter captainmitch

    (@captainmitch)

    Actually, I opened a ticket same day I posted here. They were kind enough to point me to another thread on stack overflow that suggested this:

    	add_filter('woocommerce_product_data_tabs', 'verdors_remove_tab', 98, 1);
    	function verdors_remove_tab($tabs){
    
    	    // Set HERE your targeted user role SLUG
    	    $target_user_role = 'wc_product_vendors_manager_vendor';
    
    	    // Get current user (object)
    	    $current_user = wp_get_current_user();
    	    $current_user_roles = $current_user->roles; // current user roles
    	    //echo "<H1>TESTING - TESTING</H1><br>";
        	//print_r($current_user_roles);
    
    	    // Unsetting tabs for this specific user role
    	    if( in_array( $target_user_role, $current_user_roles ) ){
        		//echo "<H1>THE IF CONDITION WAS MET</H1>";
        	    //unset($tabs['general']); // it is to remove inventory tab
        	    //unset($tabs['advanced']); // it is to remove advanced tab
        	    //unset($tabs['linked_product']); // it is to remove linked_product tab
        	    //unset($tabs['attribute']); // it is to remove attribute tab
        	    //unset($tabs['variations']); // it is to remove variations tab
        	    unset($tabs['bookings_pricing']); // it is to remove costs tab
        	    unset($tabs['bookings_persons']); // it is to remove persons tab
        	    unset($tabs['bookings_resources']); // it is to remove resources tab
        	    unset($tabs['wc_deposits']); // it is to remove the deposits tab
        	}
        	return($tabs);
    	}
    

    This does what I originally wanted in hiding the cost related tabs from the vendors with whom I have wholesale pricing agreements.

    Unfortunately, I have been unable to get the deposits tab to hide. I thought it was a priority thing, but I’ve raised the priority to 200 and still the wc-deposits tab persists.

    Plugin Support John Coy a11n

    (@johndcoy)

    Automattic Happiness Engineer

    Hi @captainmitch

    Another option to hide the deposit option from Vendors would be to apply CSS to the WP Admin using a plugin like Add Admin CSS:

    https://www.ads-software.com/plugins/add-admin-css/

    I’ll mark this issue as resolved and you can team up with another developer on our WooCommerce Developers Slack channel for custom development help:

    https://woocommerceslack.herokuapp.com

    Best,

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Product Vendors Roles and Capabilities’ is closed to new replies.