Advertisement
palsushobhan

admin-itemized-commission-invoice-link

Sep 6th, 2022
1,037
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.22 KB | None | 0 0
  1. add_filter('wcfm_orders_module_actions', function($actions, $order_id, $the_order) {
  2.     if(!current_user_can('administrator')) return $actions;
  3.     $items = $the_order->get_items( 'line_item' );
  4.     $vendors = array();
  5.     foreach($items as $item) {
  6.         $product_id = $item->get_product_id();
  7.         $vendor_id = wcfm_get_vendor_id_by_post( $product_id );
  8.         if( !wcfm_is_vendor( $vendor_id ) || in_array($vendor_id, $vendors)) continue;
  9.         $vendors[] = $vendor_id;
  10.         $store_name = wcfm_get_vendor_store_name($vendor_id);
  11.         $url = add_query_arg(
  12.             array(
  13.                 'action' => 'wcfm_order_pdf_invoice',
  14.                 'template_type' => 'invoice',
  15.                 'order_id' => $order_id,
  16.                 'vendor_id' => $vendor_id
  17.             ),
  18.             admin_url('admin-ajax.php'));
  19.         $actions .= '<a class="wcfm_pdf_invoice wcfm-action-icon" target="_blank" href="'. esc_url($url) .'" data-vendorid="'.$vendor_id.'" data-orderid="'.$order_id.'"><span class="wcfmfa fa-currence text_tip" data-tip="'.esc_attr__('Commission Invoice for ', 'wc-frontend-manager-ultimate').$store_name.'">'.get_woocommerce_currency_symbol().'</span></a>';
  20.     }
  21.     return $actions;
  22. }, 10, 3);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement