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

Migrate yith multivendor to dokan #3

Open
wants to merge 34 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
b34f0c2
YITH multivendor to dokan
Aunshon Apr 18, 2022
a7740a2
Merge remote-tracking branch 'origin/feat/wcfm-to-dokan' into feat/yi…
Aunshon May 24, 2022
5486f8a
php cs fix
Aunshon May 24, 2022
dfa2325
phpcs fix
Aunshon May 24, 2022
2366b25
Merge remote-tracking branch 'origin/feat/wcfm-to-dokan' into feat/yi…
Aunshon May 24, 2022
bde3e08
allignment fix
Aunshon May 24, 2022
5a3afad
Allignment fix
Aunshon May 24, 2022
781f5d4
Fix: wcvendors withdraw plugin select switch case
Aunshon Jul 17, 2023
a8ba56d
Fix: wcvendors withdraw plugin select switch case
Aunshon Jul 17, 2023
65412c0
Fix: wcvendors withdraw plugin select switch case
Aunshon Jul 17, 2023
9551b17
Merge branch 'develop' into feat/yithmultivendor-to-dokan
Aunshon Jul 17, 2023
3b0e761
Refactor: YITH multivendor to dokan codes.
Aunshon Jul 18, 2023
6282864
Fix: version
Aunshon Jul 19, 2023
8c2be8c
Fix: throw error when withdraw finish
Aunshon Jul 19, 2023
fe86af6
Fix: throw error when withdraw finish
Aunshon Jul 19, 2023
505ff41
Merge branch 'develop' into fix/wcfm-order-issues
Aunshon Aug 28, 2023
d3c984c
⚡️Fix: exclude dokan orders, migrate wcfm orders only.
Aunshon Aug 28, 2023
d971984
⚡️Fix: exclude dokan orders, migrate wcfm orders only.
Aunshon Aug 28, 2023
f915005
⚡️Fix: exclude dokan orders, migrate wcfm orders only.
Aunshon Aug 28, 2023
9ef1651
⚡️Fix: exclude dokan orders, migrate wcfm orders only.
Aunshon Aug 28, 2023
ca6fcd2
⚡️Fix: exclude dokan orders, migrate wcfm orders only.
Aunshon Aug 28, 2023
f467977
⚡️Fix: exclude dokan orders, migrate wcfm orders only.
Aunshon Aug 28, 2023
9e16525
⚡️HPOS support
Aunshon Aug 28, 2023
5333644
Merge branch 'develop' into feat/yithmultivendor-to-dokan
Aunshon Aug 28, 2023
a0e9566
Merge branch 'fix/wcfm-order-issues' into feat/yithmultivendor-to-dokan
Aunshon Aug 28, 2023
2ac6d32
Fix yith multivendor order support
Aunshon Aug 28, 2023
a676b13
Hpos support and order vendor id fix
Aunshon Aug 29, 2023
2c6e726
Add paged key support in api
Aunshon Sep 21, 2023
065cdcc
Merge branch 'enhancement/add-paged-key-support-in-query' into feat/y…
Aunshon Sep 22, 2023
3cab81f
Fix order migtration fatal
Aunshon Sep 25, 2023
dc2fa06
Add get seller by order abstract method
Aunshon Sep 25, 2023
5f7375e
Merge branch 'enhancement/add-paged-key-support-in-query' into feat/y…
Aunshon Sep 25, 2023
b098454
Yith order commission amount and fix vendor product owner id
Aunshon Sep 26, 2023
660a7a1
Merge branch 'develop' into feat/yithmultivendor-to-dokan
Aunshon Dec 4, 2023
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
97 changes: 97 additions & 0 deletions includes/Helpers/MigrationHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,13 +50,100 @@ public static function active_vendor_dashboard() {
$all_plugins_to_deactivate[] = WP_PLUGIN_DIR . '/wc-multivendor-marketplace/wc-multivendor-marketplace.php';
$all_plugins_to_deactivate[] = WP_PLUGIN_DIR . '/wc-multivendor-membership/wc-multivendor-membership.php';

// Yith multi vendor plugins
$all_plugins_to_deactivate[] = WP_PLUGIN_DIR . '/yith-frontend-manager-for-woocommerce-premium/init.php';
$all_plugins_to_deactivate[] = WP_PLUGIN_DIR . '/yith-woocommerce-multi-vendor-premium/init.php';

deactivate_plugins( $all_plugins_to_deactivate );

self::reset_dokan_pages();

delete_option( 'dokan_migration_completed' );

wp_send_json_success( __( 'Dokan vendor dashboard activated.', 'dokan-migrator' ) );
}

/**
* Remove and create some pages that can override dokan pages.
*
* @since 1.0.0
*
* @return void
*/
public static function reset_dokan_pages() {
$args = [
'name' => __( 'Page Installation', 'dokan-migrator' ),
'desc' => __( 'Triggering fron dokan migrator', 'dokan-migrator' ),
'button' => __( 'Install Dokan Pages', 'dokan-migrator' ),
'action' => 'create_pages',
];

$pages_to_delete = [ 'vendor_dashboard', 'vendors', 'shop_settings', 'dashboard', 'store-listing' ];

foreach ( $pages_to_delete as $page ) {
$page_obj = self::get_post_by_name( $page );

$page_obj !== null ? wp_delete_post( $page_obj->ID ) : '';
}

self::create_dokan_pages();
}

/**
* Create dokan pages.
*
* @since 1.0.0
*
* @return void
*/
public static function create_dokan_pages() {
if ( ! current_user_can( 'manage_woocommerce' ) ) {
return;
}
$pages = array(
array(
'post_title' => __( 'Dashboard', 'dokan-migrator' ),
'slug' => 'dashboard',
'page_id' => 'dashboard',
'content' => '[dokan-dashboard]',
),
array(
'post_title' => __( 'Store List', 'dokan-migrator' ),
'slug' => 'store-listing',
'page_id' => 'store_listing',
'content' => '[dokan-stores]',
),
);

$dokan_pages = array();

$old_pages = get_option( 'dokan_pages', [] );

foreach ( $pages as $page ) {
if ( in_array( $page['page_id'], array_keys( $old_pages ), true ) ) {
$dokan_pages[ $page['page_id'] ] = $old_pages[ $page['page_id'] ];
continue;
}

$page_id = wp_insert_post(
array(
'post_title' => $page['post_title'],
'post_name' => $page['slug'],
'post_content' => $page['content'],
'post_status' => 'publish',
'post_type' => 'page',
'comment_status' => 'closed',
)
);
$dokan_pages[ $page['page_id'] ] = $page_id;
}

update_option( 'dokan_pages', $dokan_pages );
flush_rewrite_rules();

update_option( 'dokan_pages_created', 1 );
}

/**
* Get post by post name
*
Expand Down Expand Up @@ -95,6 +182,10 @@ public static function get_migration_title( $plugin ) {
$title = __( 'Migrate Wcfm To Dokan', 'dokan-migrator' );
break;

case 'yithvendors':
$title = __( 'Migrate YITH WooCommerce Multi Vendor To Dokan.', 'dokan-migrator' );
break;

default:
break;
}
Expand All @@ -111,13 +202,19 @@ public static function get_migration_title( $plugin ) {
*/
public static function get_migratable_plugin() {
$active_plugins = (array) get_option( 'active_plugins', array() );

if ( is_multisite() ) {
$active_plugins = array_merge( $active_plugins, get_site_option( 'active_sitewide_plugins', array() ) );
}

// WCfM Multivendor Marketplace Check
$is_marketplace = ( in_array( 'wc-multivendor-marketplace/wc-multivendor-marketplace.php', $active_plugins, true ) || array_key_exists( 'wc-multivendor-marketplace/wc-multivendor-marketplace.php', $active_plugins ) || class_exists( 'WCFMmp' ) ) ? 'wcfmmarketplace' : false;

// YITH multi vendor marketplace Check
if ( ! $is_marketplace ) {
$is_marketplace = ( in_array( 'yith-woocommerce-multi-vendor-premium/init.php', $active_plugins, true ) || array_key_exists( 'yith-woocommerce-multi-vendor-premium/init.php', $active_plugins ) || class_exists( 'YITH_Vendors' ) ) ? 'yithvendors' : false;
}

return $is_marketplace;
}
}
2 changes: 2 additions & 0 deletions includes/Integrations/Wcfm/OrderMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -486,6 +486,8 @@ public function split_parent_order_shipping( $applied_shipping_method, $order_id
/**
* Returns all sellers of an order.
*
* @since DOKAN_MIG_SINCE
*
* @param int $order_id
*
* @return array
Expand Down
Loading
Loading