Skip to content

Commit

Permalink
fix: if a product is deleted and no vendor is found for that product …
Browse files Browse the repository at this point in the history
…display (no name) in WooCommerce order listing page (#746)

* fix: if a product is deleted and no vendor is found for that product display (no name) in woocommerce order listing page

* refactor: if dokan pro doesn't exist but commmision type is found in database, ignore that saved commission type
  • Loading branch information
saimonh3 authored Jan 31, 2020
1 parent 0448682 commit 3025eeb
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
5 changes: 3 additions & 2 deletions includes/Admin/Hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -147,9 +147,10 @@ public function shop_order_custom_columns( $col ) {
case 'seller':
$has_sub = get_post_meta( $post->ID, 'has_sub_order', true );

if ( $has_sub != '1' ) {
$seller = get_user_by( 'id', dokan_get_seller_id_by_order( $post->ID ) );
if ( $has_sub != '1' && $seller = get_user_by( 'id', dokan_get_seller_id_by_order( $post->ID ) ) ) {
printf( '<a href="%s">%s</a>', esc_url( admin_url( 'edit.php?post_type=shop_order&vendor_id=' . $seller->ID ) ), esc_html( $seller->display_name ) );
} else {
esc_html_e( '(no name)', 'dokan-lite' );
}

break;
Expand Down
21 changes: 20 additions & 1 deletion includes/Commission.php
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,10 @@ public function get_vendor_wise_earning( $vendor_id, $product_price ) {
* @return float|null on failure
*/
public function get_category_wise_earning( $product_id, $product_price ) {
if ( ! dokan()->is_pro_exists() ) {
return null;
}

return $this->prepare_for_calculation( __FUNCTION__, $product_id, $product_price );
}

Expand All @@ -403,9 +407,13 @@ public function get_category_wise_earning( $product_id, $product_price ) {
* @param int $product_id
* @param int $product_price
*
* @return float
* @return float|null on failure
*/
public function get_product_wise_earning( $product_id, $product_price ) {
if ( ! dokan()->is_pro_exists() ) {
return null;
}

return $this->prepare_for_calculation( __FUNCTION__, $product_id, $product_price );
}

Expand Down Expand Up @@ -445,6 +453,17 @@ public function prepare_for_calculation( $callable, $product_id = 0, $product_pr
$commission_type = $this->$func_type( $product_id );
}

/**
* If dokan pro doesn't exists but combine commission is found in database due to it was active before
* Then make the commission type 'flat'. We are making it flat cause when commission type is there in database
* But in option field, looks like flat commission is selected.
*
* @since DOKAN_LITE_SINCE
*/
if ( ! dokan()->is_pro_exists() && 'combine' === $commission_type ) {
$commission_type = 'flat';
}

// get[product,category,vendor,global]_wise_additional_fee
if ( is_callable( [ $this, $func_fee ] ) ) {
$additional_fee = $this->$func_fee( $product_id );
Expand Down

0 comments on commit 3025eeb

Please sign in to comment.