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

Vendor, Order, Refund, Withdraw migration #3

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
2d71dc8
Migrating data
mrabbani Jan 13, 2021
589b260
make order asc
jamilcse13 Jan 13, 2021
e7565bb
migrate refund
mrabbani Jan 13, 2021
cf99663
prepare migrate refunds query
jamilcse13 Jan 13, 2021
c4c708e
Merge branch 'master' of https://github.com/jamilcse13/migrate-to-dokan
jamilcse13 Jan 13, 2021
928a026
complete refund migration
jamilcse13 Jan 14, 2021
f6ebc5a
fix line alignment
jamilcse13 Jan 14, 2021
40793bc
create rest api endpoint
alamincse Jan 14, 2021
7a18097
Merge branch 'master' of https://github.com/jamilcse13/migrate-to-dokan
alamincse Jan 14, 2021
c0fcba7
active migrate order loop
jamilcse13 Jan 14, 2021
b01a36c
Merge branch 'master' of https://github.com/jamilcse13/migrate-to-dokan
jamilcse13 Jan 14, 2021
02b7c2b
fix issues on vendor and order migration
jamilcse13 Jan 14, 2021
58b9103
remove unused function
mrabbani Jan 14, 2021
28e7542
add permission callback for rest api
alamincse Jan 15, 2021
225ae62
Merge branch 'master' of https://github.com/jamilcse13/migrate-to-dokan
alamincse Jan 15, 2021
7b83354
connect migrations to the api endpoints
jamilcse13 Jan 15, 2021
6993bc5
fix function names
jamilcse13 Jan 15, 2021
70cddfc
adjust merge
jamilcse13 Jan 15, 2021
b7f38b9
refactor api's instance
jamilcse13 Jan 15, 2021
6cb4d3c
add migrator js
alamincse Jan 15, 2021
80e42b7
add ajax functionality for vendor migrate
alamincse Jan 17, 2021
4fb4010
fix vendor migrating issue from UI
jamilcse13 Jan 18, 2021
85f37cf
update migration UI
mrabbani Jan 18, 2021
dc2ffc6
show order count
jamilcse13 Jan 18, 2021
603b2ec
use generic migratior variable
mrabbani Jan 18, 2021
3230a5a
Merge branch 'master' of https://github.com/jamilcse13/migrate-to-dokan
jamilcse13 Jan 18, 2021
1e6ebb7
update js to show progress
mrabbani Jan 18, 2021
05a324f
handle exception
mrabbani Jan 18, 2021
d0032c5
handle migration exception
jamilcse13 Jan 18, 2021
41d443c
add php-cs for coding standard
mrabbani Jan 21, 2021
bcadd4f
fix conflict
mrabbani Jan 21, 2021
8f90e1d
refactor migrator
mrabbani Jan 21, 2021
724b9fa
fix format
mrabbani Jan 25, 2021
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
26 changes: 26 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

require_once __DIR__ . '/vendor/tareq1988/wp-php-cs-fixer/loader.php';

$finder = PhpCsFixer\Finder::create()
->exclude( 'node_modules' )
->exclude( 'vendors' )
->exclude( 'assets' )
->exclude( 'languages' )
->exclude( 'src' )
->exclude( 'bin' )
->in( __DIR__ )
;

$config = PhpCsFixer\Config::create()
->registerCustomFixers( [
new WeDevs\Fixer\SpaceInsideParenthesisFixer(),
new WeDevs\Fixer\BlankLineAfterClassOpeningFixer(),
] )
->setRiskyAllowed( true )
->setUsingCache( false )
->setRules( WeDevs\Fixer\Fixer::rules() )
->setFinder( $finder )
;

return $config;
33 changes: 13 additions & 20 deletions assets/css/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,34 +20,20 @@
display: none
}
.migrate-to-dokan .action-button {
width: 100px;
/* width: 100px; */
background: #EF545D;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 0px;
cursor: pointer;
padding: 10px 5px;
padding: 10px 25px;
margin: 10px 0px 10px 5px;
border-radius: 5px;
text-decoration: none;
/* float: right */
}

.migrate-to-dokan .action-button-previous {
width: 100px;
background: #616161;
font-weight: bold;
color: white;
border: 0 none;
border-radius: 0px;
cursor: pointer;
padding: 10px 5px;
margin: 10px 5px 10px 0px;
/* float: right */
}
.migrate-to-dokan .action-button-previous:hover,
.migrate-to-dokan .action-button-previous:focus {
background-color: #EF545D;
}
.card {
z-index: 0;
border: none;
Expand Down Expand Up @@ -151,6 +137,13 @@ input[type="button"] {
width: 80%;
margin: auto;
}
.btn-group{

}
#success> li{
padding: 5px 0;
}
#success> li.success{
color: green;
}
.success{
color: green;
}
97 changes: 97 additions & 0 deletions assets/js/dokan-loader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
var DokanMigrator = {
init: function() {
this.bindEvents();
},
bindEvents: function() {
var self = this;

$('#start-migration').click(function() {

window.onbeforeunload = self.confirmReload;

self.migrateVendor();
});
},
confirmReload: function(event) {
return confirm("Confirm refresh");
},
migrateVendor: function() {
this.showMessage('Migrating vendor, please wait..')

this.migrateData(vendorUrl, this.migrateRefund.bind(this));
},
migrateRefund: function() {
this.showMessage('Vendor migration complete', 'success')
this.showMessage('Migrating refund, please wait..')

this.migrateData(refundUrl, this.migrateWithdraw.bind(this));
},
migrateWithdraw: function() {
var self = this;
this.showMessage('Refund migration complete', 'success')
this.showMessage('Migrating withdraw, please wait..')

self.migrateData(withdrawUrl, self.migrateOrder.bind(self))
},
migrateOrder: function() {
this.showMessage('Withdraw migration complete', 'success')
this.showMessage(' Migrating order <span class="success" id="order-progress">0%</span>, please wait..')
this.migrateOrderByPage(1);
},
migrateOrderByPage: function(page, per_page) {
page = page || 1;
per_page = per_page || 1;

var self = this;

$.get(orderUrl + '?page=' + page + '&per_page=' + per_page, function(response) {
var total = response.total;
var page_total = response.per_page * response.current_page;
if (page_total > total) {
page_total = total;
}
var percent = (page_total || 1) / (total || 1) * 100;

$(document).find('#order-progress').text(parseInt(percent) + '%')
if (response.next_page && response.next_page > 0) {
self.migrateOrderByPage(response.next_page, response.per_page);
} else {
self.onMigrationSuccess()
}
})
.fail(function(error) {
console.log(error.responseText);
$('#success').html(error.responseText);
});
},

showMessage: function(msg, styleClass) {
styleClass = styleClass || ''
$('#success').append('<li class="' + styleClass +'">' + msg +'</li>')

},
onMigrationSuccess: function() {
this.showMessage('Order migration complete', 'success')
// alert('Migrate Order')
window.onbeforeunload = null;
setTimeout( function() {
$('#migration-success').trigger('click');
$('#step-2,#step-1').hide(200);
$('#step-3').show(300);
}, 3000);
},
migrateData: function(url, callback) {
$.get(url, function(response) {
console.log('Success');
if (callback) {
callback();
}
})
.fail(function(error) {
console.log(error.responseText);
$('#success').html(error.responseText);
});
}
}

DokanMigrator.init();
11 changes: 10 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,19 @@
],
"minimum-stability": "dev",
"require": {},
"require-dev": {
"wp-coding-standards/wpcs": "dev-master",
"dealerdirect/phpcodesniffer-composer-installer": "^0.4.3",
"tareq1988/wp-php-cs-fixer": "dev-master",
"phpcompatibility/phpcompatibility-wp": "dev-master",
"phpunit/phpunit": ">=6.5.14"
},
"autoload": {
"psr-4": {
"WeDevs\\MigrateToDokan\\": "includes/"
},
"files": []
"files": [
"helpers/index.php"
]
}
}
30 changes: 30 additions & 0 deletions helpers/index.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?php

if (! function_exists( 'migrate_to_dokan_get_vendors' ) ) {
function migrate_to_dokan_get_vendors( $roles = [] ) {
$vendors = [];

if (! count( $roles ) ) {
$roles = [
'wcfm_vendor',
'disable_vendor', //wcfm disabled vendors
];
}
// var_dump( $roles);
$args = [
'role__in' => $roles,
// 'number' => 10,
// 'offset' => 0,
'orderby' => 'registered',
'order' => 'ASC',
'status' => 'approved',
'featured' => '', // yes or no
'meta_query' => [],
];

$user_query = new WP_User_Query( $args );
$vendors = $user_query->get_results();

return $vendors;
}
}
Loading