Advertisement
palsushobhan

show vendor earning column

Jun 2nd, 2021
249
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.04 KB | None | 0 0
  1. add_filter( 'wcfm_orders_additional_info_column_label', function( $column_label ) {
  2.     if(wcfm_is_vendor()) return 'My earning';
  3.     return "Vendor's earning";
  4. });
  5.  
  6. add_filter( 'wcfm_orders_additonal_data_hidden', '__return_false' );
  7.  
  8. add_filter( 'wcfm_orders_additonal_data', function( $column_data, $order_id ) {
  9.     global $WCFM;
  10.     $the_order = wc_get_order( $order_id );
  11.  
  12.     if ( ! is_a( $the_order, 'WC_Order' ) )
  13.         return __( 'N/A', 'wc-frontend-manager' );
  14.  
  15.     $order_status = sanitize_title( $the_order->get_status() );
  16.     $order_currency = $the_order->get_currency();
  17.     $commission = $WCFM->wcfm_vendor_support->wcfm_get_commission_by_order( $order_id );
  18.  
  19.     if ( ! $commission || in_array( $order_status, array( 'failed', 'cancelled', 'refunded', 'request', 'proposal', 'proposal-sent', 'proposal-expired', 'proposal-rejected', 'proposal-canceled', 'proposal-accepted' ) ) ) {
  20.         return __( 'N/A', 'wc-frontend-manager' );
  21.     }
  22.  
  23.     return wc_price( $commission, array( 'currency' => $order_currency ) );
  24. }, 50, 2 );
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement