Skip to content

Commit

Permalink
Fix order migtration fatal
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunshon committed Sep 25, 2023
1 parent 065cdcc commit 3cab81f
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 29 deletions.
36 changes: 22 additions & 14 deletions includes/Integrations/YithMultiVendor/OrderMigrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@
*/
class OrderMigrator extends OrderMigration {

/**
* Class constructor.
*
* @since DOKAN_MIG_SINCE
*
* @param \WC_Order $order
*/
public function __construct( \WC_Order $order ) {
$this->order_id = $order->ID;
$this->order = $order;
}
/**
* Class constructor.
*
* @since DOKAN_MIG_SINCE
*
* @param \WC_Order $order
*/
public function __construct( \WC_Order $order ) {
$this->order_id = $order->get_id();
$this->order = $order;
}

/**
* Create sub order if needed
Expand Down Expand Up @@ -75,7 +75,7 @@ public function add_splited_shipping( $order, $parent_order ) {
if ( $shipping_methods ) {
foreach ( $shipping_methods as $method_item_id => $shipping_object ) {
$shipping_method = $shipping_object;
break;
break;
}
}

Expand Down Expand Up @@ -161,7 +161,10 @@ public function get_dokan_order_data( $parent_order_id, $seller_id ) {
$orders = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$wpdb->prefix}yith_vendors_commissions WHERE user_id = %d AND order_id=%d", $seller_id, $sub_order->get_id() ) );

foreach ( $orders as $order ) {
$net_amount += $order->amount - abs( $order->amount_refunded );
$refunded_amount = isset( $order->amount_refunded ) ? $order->amount_refunded : 0;

$current_net_amount = isset( $order->amount ) ? $order->amount : 0;
$net_amount += $current_net_amount - $refunded_amount;

$res_commission = [
'type' => 'percent',
Expand All @@ -174,7 +177,12 @@ public function get_dokan_order_data( $parent_order_id, $seller_id ) {
];

$unit_commissin_rate_admin = 100 - ( $order->rate * 100 );
$new_admin_commissin = ( $wc_order->get_subtotal() * $unit_commissin_rate_admin ) / 100;

if ( $current_net_amount ) {
$new_admin_commissin = $sub_order->get_subtotal() - $current_net_amount;
} else {
$new_admin_commissin = ( $sub_order->get_subtotal() * $unit_commissin_rate_admin ) / 100;
}

$res_commission['percentage'] = $unit_commissin_rate_admin;
$res_commission['admin_commission'] = $new_admin_commissin;
Expand Down
54 changes: 39 additions & 15 deletions languages/dokan-migrator.pot
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright (c) 2022 weDevs Pte. Ltd. All Rights Reserved.
# Copyright (c) 2023 weDevs Pte. Ltd. All Rights Reserved.
msgid ""
msgstr ""
"Project-Id-Version: Dokan Migrator 1.0.0\n"
Expand All @@ -8,9 +8,9 @@ msgstr ""
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"POT-Creation-Date: 2022-10-18T06:15:22+00:00\n"
"POT-Creation-Date: 2023-09-25T06:00:19+00:00\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"X-Generator: WP-CLI 2.6.0\n"
"X-Generator: WP-CLI 2.7.1\n"
"X-Domain: dokan-migrator\n"

#. Plugin Name of the plugin
Expand All @@ -35,49 +35,73 @@ msgstr ""
msgid "https://WeDevs.com/"
msgstr ""

#: includes/Helpers/MigrationHelper.php:57
#: includes/Helpers/MigrationHelper.php:63
msgid "Dokan vendor dashboard activated."
msgstr ""

#: includes/Helpers/MigrationHelper.php:91
#: includes/Helpers/MigrationHelper.php:75
msgid "Page Installation"
msgstr ""

#: includes/Helpers/MigrationHelper.php:76
msgid "Triggering fron dokan migrator"
msgstr ""

#: includes/Helpers/MigrationHelper.php:77
msgid "Install Dokan Pages"
msgstr ""

#: includes/Helpers/MigrationHelper.php:105
msgid "Dashboard"
msgstr ""

#: includes/Helpers/MigrationHelper.php:111
msgid "Store List"
msgstr ""

#: includes/Helpers/MigrationHelper.php:178
msgid "Migrate to dokan"
msgstr ""

#: includes/Helpers/MigrationHelper.php:95
#: includes/Helpers/MigrationHelper.php:182
msgid "Migrate Wcfm To Dokan"
msgstr ""

#: includes/Helpers/MigrationHelper.php:186
msgid "Migrate YITH WooCommerce Multi Vendor To Dokan."
msgstr ""

#: includes/Migrator/Ajax.php:59
msgid "Item count successfull."
msgstr ""

#: includes/Migrator/Ajax.php:93
#: includes/Migrator/Ajax.php:94
msgid "Import successfull."
msgstr ""

#: includes/Migrator/Ajax.php:117
#: includes/Migrator/Ajax.php:118
msgid "Nonce verification failed!"
msgstr ""

#: includes/Migrator/Manager.php:215
#: includes/Migrator/Manager.php:235
msgid "Invalid import type"
msgstr ""

#: includes/Processors/Order.php:79
#: includes/Processors/Vendor.php:91
#: includes/Processors/Withdraw.php:96
#: includes/Processors/Order.php:127
#: includes/Processors/Vendor.php:109
#: includes/Processors/Withdraw.php:110
msgid "Migrator class not found"
msgstr ""

#: includes/Processors/Order.php:94
#: includes/Processors/Order.php:142
msgid "No orders found to migrate to dokan."
msgstr ""

#: includes/Processors/Vendor.php:104
#: includes/Processors/Vendor.php:122
msgid "No vendors found to migrate to dokan."
msgstr ""

#: includes/Processors/Withdraw.php:124
#: includes/Processors/Withdraw.php:138
msgid "No withdraws found to migrate to dokan."
msgstr ""

Expand Down

0 comments on commit 3cab81f

Please sign in to comment.