Support » Plugin: YITH WooCommerce Multi Vendor » Issue with displaying orders

  • Vendors are getting “access denied” errors to orders if they only have order types of “suborder”.

    In class.yith-vendors-admin.php, line 435 we have the following:

    
    if( $post && 'shop_order' == $post->post_type ){
        $vendor_orders = $vendor->get_orders( 'all' );
        if( $is_seller && ! in_array( $post->ID, $vendor_orders ) ){
            wp_die( sprintf( __( 'You do not have permission to edit this order. %1$sClick here to view and edit your orders%2$s.', 'yith-woocommerce-product-vendors' ), '<a href="' . esc_url( 'edit.php?post_type=shop_order' ) . '">', '</a>' ) );
        }
    }
    

    Note the line:

    $vendor_orders = $vendor->get_orders( 'all' );
    

    Looking at the get_orders function (class.yith-vendor.php) I notice that the ‘all’ flag only checks the commission table for orders

    $query = $wpdb->prepare ( "SELECT DISTINCT order_id FROM {$wpdb->commissions} WHERE vendor_id = %d", $this->id );

    As we don’t have any commission orders in place, this means that suborders and quotes will never be allowed to be viewed by the vendors.

    I’d recommend changing the ‘all’ query to something more appropriate so all orders are actually found. For now I’m changing the plugin core code to the below, but it’s definitely not ideal to be doing this…

    if( $post && 'shop_order' == $post->post_type ){
         $vendor_orders = $vendor->get_orders( 'suborder' );
    
         if( $is_seller && ! in_array( $post->ID, $vendor_orders ) ){
            wp_die( sprintf( __( 'You do not have permission to edit this order. %1$sClick here to view and edit your orders%2$s.', 'yith-woocommerce-product-vendors' ), '<a href="' . esc_url( 'edit.php?post_type=shop_order' ) . '">', '</a>' ) );
         }
    }
    • This topic was modified 5 years, 8 months ago by Scott Bowler.
Viewing 1 replies (of 1 total)
  • Plugin Author YITHEMES

    (@yithemes)

    Hi,

    the args ‘all’ is only a support for old version of multi vendor plugin.
    If you can’t access to orders page the reason is not linked to this code.
    However, this problem just already solved in version 1.9.12 that our developers released on 14 July 2016.

    Are you sure to use the latest plugin version ?
    If not you can try to update the plugin to latest version.
    Another solution is to deactivate and then reactivate the multi vendor plugin.
    In this way the plugin regenerate all vendor capabilities, sometimes during update process the plugin can’t regenerate the user (vendor) capabilities, in this wya you can fix this problem.

    Please try this solution and let me know if works for you.
    Have a nice day
    YITH

Viewing 1 replies (of 1 total)
  • The topic ‘Issue with displaying orders’ is closed to new replies.