Skip to content

Commit

Permalink
Fix commission upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
Aunshon committed Nov 22, 2024
1 parent f26fd56 commit 27fa0e1
Showing 1 changed file with 16 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -97,26 +97,26 @@ private function update_global_settings( $terms ) {
*/
private function update_vendors_settings( $vendors ) {
foreach ( $vendors as $vendor ) {
$commission = $vendor->get_commission_settings();
$commission = $vendor->get_commission_settings();

$commission_type_old = $commission->get_type();
$commission->set_type( Fixed::SOURCE );

$commission_type = $commission->get_type();
$flat = $commission->get_flat();
$percentage = $commission->get_percentage();
$percentage = $commission->get_percentage();

if ( Flat::SOURCE === $commission_type_old ) {
$percentage = 0;
$flat = $percentage;
$commission->set_percentage( 0 );
$commission->set_flat( $percentage );
} elseif ( Percentage::SOURCE === $commission_type_old ) {
$flat = 0;
$commission->set_percentage( $percentage );
$commission->set_flat( 0 );
}

$vendor->save_commission_settings(
[
'type' => $commission_type,
'flat' => $flat,
'percentage' => $percentage,
'type' => $commission->get_type(),
'flat' => $commission->get_flat(),
'percentage' => $commission->get_percentage(),
'category_commissions' => $commission->get_category_commissions(),
]
);
Expand All @@ -141,23 +141,19 @@ private function update_products_settings( $posts ) {
$commission_type_old = $commission->get_type();
$commission->set_type( Fixed::SOURCE );

$commission_type = $commission->get_type();
$flat = $commission->get_flat();
$percentage = $commission->get_percentage();

if ( Flat::SOURCE === $commission_type_old ) {
$percentage = 0;
$flat = $percentage;
$commission->set_flat( $commission->get_percentage() );
$commission->set_percentage( 0 );
} elseif ( Percentage::SOURCE === $commission_type_old ) {
$flat = 0;
$commission->set_flat( 0 );
}

dokan()->product->save_commission_settings(
$post->ID,
[
'type' => $commission_type,
'percentage' => $percentage,
'flat' => $flat,
'type' => $commission->get_type(),
'percentage' => $commission->get_percentage(),
'flat' => $commission->get_flat(),
]
);
}
Expand Down

0 comments on commit 27fa0e1

Please sign in to comment.