File: Manager.php
Namespace: namespace WeDevs\Dokan\Vendor;
Location : dokan-lite\includes\Vendor\Manager.php
Vendor manager class. This class holds lot of methods that helps to get and save information about vendors.
Vendor manager class api #
- Get all vendors: #
dokan()->vendor->all();
- Get vendors as arguments passed: #
dokan()->vendor->get_vendors( $args );
- Get single vendor data: #
dokan()->vendor->get( $vendor );
- Create a vendor: #
dokan()->vendor->create( $data );
- Update vendor: #
dokan()->vendor->update( $data );
- Delete a vendor: #
dokan()->vendor->delete( $vendor_id, null );
- Get featured all vendors or as arguments passed: #
dokan()->vendor->get_featured( $args );
Vendor manager class methods reference #
Method : all ( array $args )
Method type #
non-static
Description #
Get all vendors. It calls the get_vendors() method. And its arguments are the same as get_vendors() function.
Parameters #
$args
(array)(optional) Different parameters to get vendors..
- role__in
( array ) array of roles default [ ‘seller’, ‘administrator’ ] - number
( integer ) number of posts default 10 - offset
( integer ) Retrieve from id default 0 - orderby
( string ) get vendors by default registered - order
( string ) show result in ascending or descending default ASC - status
( array ) vendor status default [ ‘approved’ ] - featured
( string ) value can be yes or no default ” - meta_query
( array ) custom meta agruments. - fields
( string ) default ‘all’
Returns #
( array ) array of all vendors means array of all vendor user information.
More information #
Usage #
$all_vendors = dokan()->vendor->all();
print_r( $all_vendors ); // Returns 10 vendors in an array by default.
Output #
Returns 10 vendors in an array by default with no arguments.
Method : get_vendors( $args = [] )
Method type #
non-static
Description #
Get vendors as an array based on arguments.
Parameters #
$args
(array)(optional) Different parameters to get vendors..
- role__in
( array ) array of roles default [ ‘seller’, ‘administrator’ ] - number
( integer ) number of posts default 10 - offset
( integer ) Retrieve from id default 0 - orderby
( string ) get vendors by default registered - order
( string ) show result in ascending or descending default ASC - status
( array ) vendor status default [ ‘approved’ ] - featured
( string ) value can be yes or no default ” - meta_query
( array ) custom meta agruments. - fields
( string ) default ‘all’
Return #
( array ) array of queried vendors.
More informaiton #
Usage #
$defaults = [
'role__in' => [ 'seller', 'administrator' ],
'number' => 10,
'offset' => 0,
'orderby' => 'registered',
'order' => 'ASC',
'status' => [ 'approved' ],
'featured' => 'yes',
'meta_query' => [],
'fields' => 'all',
];
$all_vendors = dokan()->vendor->get_vendors( $args );
print_r( $all_vendors ); // Returns vendors in an array.
Alternative global function #
dokan_get_sellers( $args = [] );
Output #
Returns 10 vendors.
Method : get( object | int $vendor )
Method type
non-static
Description #
Get single vendor data by vendor id or vendor user object. Which means it returns a total vendors object from where you can extract any informations.
Parameters #
- $vendor
( Object | integer ) Vendor user id or full user object.
Returns #
( object ) vendor instance or vendor/user full object.
More information #
Usage #
$vendor = dokan()->vendor->get( 11 );
print_r( $vendor );
Alternate function #
dokan_get_store_info( int $seller_id | object $seller );
Output #
Returns Vendor() object.
Method : create( array $data = [] )
Method type #
non-static
Description #
Create a vendor by providing needed credentials.
Parameter #
$data
( array ) Vendor or a users basic information personal and store information
- role
( string ) vendor role default seller - user_login
( string ) vendor username - user_pass
( string ) vendor password - email
( string ) vendor email address - notify_vendor
( string ) Sends notification both vendor and admin accepts ( 1/0, yes/no, on/off ) - store_name
( string ) vendors store name - social
( array ) array of social links facebook, instagram and twitter ans more. - payment
( array ) array of payment datas.- paypal
( array ) array of paypal informaiton.- Email – string
- bank
( array ) Bank account information
- paypal
- phone
( string ) Vendor phone number - show_email
( string ) show vendor email to customer default no - address
( array ) address line 1 and address line 2 information. - location
( string ) vendor location. - banner
- ( integer ) banner id default 0
- icon
( string ) vendor icon - gravatar
( integer ) vendor gravatar id default 0 - show_more_ptab
( string ) vendor show more product tab default ‘yes’ - store_ppp
( integer ) vendor store product per page default 10 - enable_tnc
( string ) terms and condition default off - store_tnc
( string ) Terms and condition text. - show_min_order_discount
( string ) default no - store_seo
( array ) default [] - dokan_store_time
( array ) vendor store opening and closing time array - enabled
( string ) enable vendor status, accepts ( 1/0, yes/no, on/off ) - featured
( string ) is this vendor is a featured seller, accepts ( 1/0, yes/no, on/off ) - trusted
( string ) enable publishing product directly, accepts ( 1/0, yes/no, on/off )
Returns #
( object | Wp_Error ) created vendor object or wp error object.
Hooks #
dokan_before_create_vendor ( action )
dokan_new_vendor ( action )
More information #
Usage #
$data = [
'role' => 'seller',
'user_login' => 'username',
'user_pass' => 'password',
'email' => '[email protected]',
'notify_vendor' => 'yes',
'store_name' => 'store name',
'social' => [
'facebook' => 'https :/ /www.facebook.com',
],
'payment' => [
'paypal' => [
'email' => '[email protected]',
]
],
'bank' => [],
'phone' => '+8801200000000',
'show_email' => 'no',
'address' => 'full address',
'location' => 'lat long',
'banner' => 0,
'icon' => '',
'gravatar' => 0,
'show_more_ptab' => 'yes',
'store_ppp' => 10,
'enable_tnc' => 'off',
'store_tnc' => 'Term and condition text',
'show_min_order_discount' => 'no',
'store_seo' => [],,
'dokan_store_time' => [],,
'enabled' => 'yes',
'featured' => 'yes',
'trusted' => 'yes',
];
$created_vendor = dokan()->vendor->create( $data );
print_r( $created_vendor );
Output #
Created vendor object.
Method : get_featured( array $args = [] )
Method type #
non-static
Description #
Get all featured vendors or as arguments passed.
Parameters #
$args
( array ) Gives all featured vendors or gives vendors as the arguments passed
- number
( integer ) number of vendors default 10 - offset
( integer ) vendor id list start - featured
( string ) is vendors are featured, accepted ( yes/no ) default yes
Returns #
( array ) all featured vendors.
More information #
Usage #
$get_vendor = dokan()->vendor->get_featured( $args );
print_r( $get_vendor );
Output #
Array of vendors.
Method : delete( int $vendor_id, Null $reassign )
Method type #
non-static
Description #
Delete a vendor by vendor id with reassign dara
Parameters #
$vendor_id
( int ) Vendor user id.
$reassign
( null ) default null and other accepted param is ‘novalue’. if you set novalue then current vendors posts will not be deleted and author id will be 0 or if you set null all post will be deleted with this author.
Return #
( Boolean ) if the vendor is deleted or not.
More information #
Usage #
$is_vendor_deleted = dokan()->vendor->delete( $vendor_id, $reassign = null );
if ( $is_vendor_deleted ){
// DO something.
}