Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add $data parameter to dokan_update_vendor hook #2386

Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion includes/Vendor/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@
'order' => 'ASC',
'status' => [ 'approved' ],
'featured' => '', // yes or no
'meta_query' => [],

Check warning on line 55 in includes/Vendor/Manager.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Detected usage of meta_query, possible slow query.
'fields' => 'all',
];

Expand All @@ -69,7 +69,7 @@

$meta_query[] = [
'key' => 'dokan_enable_selling',
'value' => ( $stat == 'approved' ) ? 'yes' : 'no',

Check failure on line 72 in includes/Vendor/Manager.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Loose comparisons are not allowed. Expected: "==="; Found: "=="
'compare' => '=',
];
}
Expand All @@ -78,11 +78,11 @@
$args['meta_query']['relation'] = 'AND';
$args['meta_query'][] = $meta_query;
} else {
$args['meta_query'] = $meta_query;

Check warning on line 81 in includes/Vendor/Manager.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Detected usage of meta_query, possible slow query.
}

// if featured
if ( 'yes' == $args['featured'] ) {

Check failure on line 85 in includes/Vendor/Manager.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Loose comparisons are not allowed. Expected: "==="; Found: "=="
$args['meta_query']['relation'] = 'AND';
$args['meta_query'][] = [
'key' => 'dokan_feature_seller',
Expand Down Expand Up @@ -168,7 +168,7 @@
/**
* @since 3.2.7 added $data parameter
*/
$store_data = apply_filters( 'dokan_vendor_create_data', [

Check failure on line 171 in includes/Vendor/Manager.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Opening parenthesis of a multi-line function call must be the last content on the line
'store_name' => ! empty( $data['store_name'] ) ? $data['store_name'] : '',
'social' => ! empty( $data['social'] ) ? $data['social'] : [],
'payment' => ! empty( $data['payment'] ) ? $data['payment'] : [
Expand All @@ -187,7 +187,7 @@
'show_min_order_discount' => ! empty( $data['show_min_order_discount'] ) ? $data['show_min_order_discount'] : 'no',
'store_seo' => ! empty( $data['store_seo'] ) ? $data['store_seo'] : [],
'dokan_store_time' => ! empty( $data['store_open_close'] ) ? $data['store_open_close'] : [],
], $data );

Check failure on line 190 in includes/Vendor/Manager.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Closing parenthesis of a multi-line function call must be on a line by itself

$vendor = dokan()->vendor->get( $vendor_id );

Expand Down Expand Up @@ -353,7 +353,7 @@

// for backward compatibility we'll allow both `enable_tnc` and `toc_enabled` to set store trams and condition settings
if ( ( isset( $data['enable_tnc'] ) && dokan_validate_boolean( $data['enable_tnc'] ) )
|| ( isset( $data['toc_enabled'] ) && dokan_validate_boolean( $data['toc_enabled'] ) ) ) {

Check warning on line 356 in includes/Vendor/Manager.php

View workflow job for this annotation

GitHub Actions / Run PHPCS inspection

Found precision alignment of 1 spaces.
$vendor->set_enable_tnc( 'on' );
} else {
$vendor->set_enable_tnc( 'off' );
Expand Down Expand Up @@ -429,11 +429,27 @@
}
}

/**
* Fires before a vendor is updated.
*
* @since [insert version number here]
*
* @param int $vendor_id The ID of the vendor being updated.
* @param array $data The array of vendor data being updated.
*/
do_action( 'dokan_before_update_vendor', $vendor->get_id(), $data );

$vendor->save();

do_action( 'dokan_update_vendor', $vendor->get_id() );
/**
* Fires after a vendor has been updated.
*
* @since [insert version number here]
*
* @param int $vendor_id The ID of the vendor that was updated.
* @param array $data The array of vendor data that was updated.
*/
do_action( 'dokan_update_vendor', $vendor->get_id(), $data );

return $vendor->get_id();
}
Expand Down
Loading