Skip to content

Commit a646e2c

Browse files
committed
migrating
1 parent e10a5be commit a646e2c

File tree

3 files changed

+39
-21
lines changed

3 files changed

+39
-21
lines changed

includes/Admin/Menu.php

+11-3
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,15 @@
55
class Menu {
66
function __construct() {
77
add_action( 'admin_menu', [ $this, 'add_migrate_to_dokan_menu' ] );
8-
add_action( 'admin_init', [ $this, 'setup_wizard' ] );
8+
if (isset($_GET['page']) && $_GET['page'] == 'migrate-to-dokan'){
9+
add_action( 'admin_init', [ $this, 'setup_wizard' ] );
10+
}
911

1012
}
1113

1214
public function add_migrate_to_dokan_menu() {
13-
// add_menu_page( __( 'Migrate to Dokan', 'weDevs'), __( 'Migrate To Dokan', 'weDevs'), 'manage_options', 'migrate-to-dokan-menu', [ $this, 'add_migrate_to_dokan_page' ], 'dashicons-database' );
14-
add_submenu_page( null, '', '', 'manage_options', 'migrate-to-dokan1' );
15+
add_menu_page( __( 'Migrate to Dokan', 'weDevs'), __( 'Migrate To Dokan', 'weDevs'), 'manage_options', 'migrate-to-dokan-menu', [ $this, 'migrate' ], 'dashicons-database' );
16+
add_submenu_page( null, '', '', 'manage_options', 'migrate-to-dokan' );
1517
//echo 'alkdsfads'; die;
1618
}
1719

@@ -35,4 +37,10 @@ public function setup_wizard() {
3537
// include_once $template;
3638
// }
3739
}
40+
41+
public function migrate()
42+
{
43+
$migrator = Migrator_Manager::get_migrator();
44+
$migrator->migrate();
45+
}
3846
}

includes/Admin/Migrators/WCFM_Migrator.php

+26-10
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ protected function get_vendor_counts()
5151

5252
public function migrate()
5353
{
54-
return 'Success';
54+
$this->store_setting_migrate(3);
5555
}
5656

5757
function dokan_allwoed_vendor_user_roles( $user_roles ) {
@@ -67,8 +67,11 @@ public function store_setting_migrate( $vendor_id ) {
6767

6868
$vendor_user = get_userdata( $vendor_id );
6969

70-
$vendor_data = get_user_meta( $vendor_id, 'dokan_profile_settings', true );
71-
70+
// $vendor_data = get_user_meta( $vendor_id, 'dokan_profile_settings', true );
71+
$vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true );
72+
73+
// var_dump($vendor_data);
74+
7275
if( !$vendor_data || ( $vendor_data && !is_array( $vendor_data ) ) ) $vendor_data = array();
7376

7477
$vendor_data['banner_type'] = 'single_img';
@@ -109,15 +112,28 @@ public function store_setting_migrate( $vendor_id ) {
109112
$vendor_data['address']['zip'] = isset( $vendor_data['customer_support']['zip'] ) ? $vendor_data['customer_support']['zip'] : '';
110113

111114
// Store Policy
112-
$wcfm_policy_vendor_options = array();
113-
$wcfm_policy_vendor_options['policy_tab_title'] = '';
114-
$wcfm_policy_vendor_options['shipping_policy'] = get_user_meta( $vendor_id, '_dps_ship_policy', true );
115-
$wcfm_policy_vendor_options['refund_policy'] = get_user_meta( $vendor_id, '_dps_refund_policy', true );
116-
$wcfm_policy_vendor_options['cancellation_policy'] = get_user_meta( $vendor_id, '_dps_refund_policy', true );
117-
update_user_meta( $vendor_id, 'wcfm_policy_vendor_options', $wcfm_policy_vendor_options );
115+
// $wcfm_policy_vendor_options = array();
116+
// $wcfm_policy_vendor_options['policy_tab_title'] = '';
117+
// $wcfm_policy_vendor_options['shipping_policy'] = get_user_meta( $vendor_id, '_dps_ship_policy', true );
118+
// $wcfm_policy_vendor_options['refund_policy'] = get_user_meta( $vendor_id, '_dps_refund_policy', true );
119+
// $wcfm_policy_vendor_options['cancellation_policy'] = get_user_meta( $vendor_id, '_dps_refund_policy', true );
120+
// update_user_meta( $vendor_id, 'wcfm_policy_vendor_options', $wcfm_policy_vendor_options );
118121

122+
123+
$wcfm_policies = get_user_meta( $vendor_id, 'wcfm_policy_vendor_options', true );
124+
update_user_meta($vendor_id, '_dps_ship_policy', isset($wcfm_policies['shipping_policy']) ? $wcfm_policies['shipping_policy'] : '');
125+
126+
$refund_policy = isset($wcfm_policies['refund_policy']) ? $wcfm_policies['refund_policy'] : null;
127+
128+
$refund_policy .= isset($wcfm_policies['cancellation_policy']) ? ('; ' . $wcfm_policies['cancellation_policy']) : null;
129+
130+
update_user_meta($vendor_id, '_dps_refund_policy', $refund_policy);
131+
132+
update_user_meta( $vendor_id, 'wcfm_policy_vendor_options', $wcfm_policy_vendor_options );
133+
119134
// Store SEO
120135
$vendor_data['store_seo']['wcfmmp-seo-meta-title'] = isset( $vendor_data['store_seo']['dokan-seo-meta-title'] ) ? $vendor_data['store_seo']['dokan-seo-meta-title'] : '';
136+
$vendor_data['store_seo']['wcfmmp-seo-meta-title'] = isset( $vendor_data['store_seo']['dokan-seo-meta-title'] ) ? $vendor_data['store_seo']['dokan-seo-meta-title'] : '';
121137
$vendor_data['store_seo']['wcfmmp-seo-meta-desc'] = isset( $vendor_data['store_seo']['dokan-seo-meta-desc'] ) ? $vendor_data['store_seo']['dokan-seo-meta-desc'] : '';
122138
$vendor_data['store_seo']['wcfmmp-seo-meta-keywords'] = isset( $vendor_data['store_seo']['dokan-seo-meta-keywords'] ) ? $vendor_data['store_seo']['dokan-seo-meta-keywords'] : '';
123139
$vendor_data['store_seo']['wcfmmp-seo-og-title'] = isset( $vendor_data['store_seo']['dokan-seo-og-title'] ) ? $vendor_data['store_seo']['dokan-seo-og-title'] : '';
@@ -440,7 +456,7 @@ public function store_order_migrate( $vendor_id ) {
440456
if( $commission_id ) {
441457

442458
// Commission Ledger Update
443-
$reference_details = sprintf( __( 'Commission for %s order.', 'wc-multivendor-marketplace-migration' ), '<b>' . get_the_title( $product_id ) . '</b>' );
459+
$reference_details = sprintf( __( 'Commission for %s order.', 'wc-multivendor-marketplace-migration' ), '<br>' . get_the_title( $product_id ) . '</br>' );
444460
try {
445461
$wpdb->query(
446462
$wpdb->prepare(

migrate-to-dokan.php

+2-8
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ private function __construct() {
2525
$this->define_constants();
2626
$this->instance();
2727

28-
//register_activation_hook( __FILE__, [ $this, 'activate' ] );
28+
register_activation_hook( __FILE__, [ $this, 'activate' ] );
2929

3030
// add_action( 'init', [ $this, 'init_plugin' ] );
3131

@@ -67,13 +67,7 @@ public function define_constants() {
6767
}
6868

6969
public function activate() {
70-
echo 2;
71-
// new WeDevs\MigrateToDokan\Admin\Welcome();
72-
if ($_GET['page'] !== 'migrate-to-dokan1') {
73-
wp_safe_redirect(admin_url('admin.php?page=migrate-to-dokan1'));
74-
}
75-
76-
exit();
70+
7771
}
7872
}
7973

0 commit comments

Comments
 (0)