Last active
October 18, 2025 09:41
-
-
Save mahircoding/9d8a554498fba0288b2f43dac416b1eb to your computer and use it in GitHub Desktop.
custom jv manager sejoli
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Set complete earning | |
| * Hooked via action sejoli/order/set-status/completed, priority 1999 | |
| * @param array $order_data | |
| */ | |
| public function set_complete_earning( array $order_data ) { | |
| $order_id = $order_data['ID']; | |
| sejoli_jv_update_earning_status( $order_id, 'added' ); | |
| $order_id = $order_data['ID']; | |
| $order_detail = sejolisa_get_order( array('ID' => $order_id )); | |
| $order = $order_detail['orders']; | |
| $jv_setup = sejoli_jv_get_product_setup( $order['product_id'] ); | |
| $order_total = floatval( $order['grand_total'] ); | |
| if( false === $jv_setup || 0 >= $order_total) : | |
| return; | |
| endif; | |
| foreach( $jv_setup as $setup ) : | |
| $value = floatval( $setup['value_portion'] ); | |
| if( 'percentage' === $setup['value_type'] ) : | |
| $value = floor( $nett_total * $value / 100 ); | |
| endif; | |
| endforeach; | |
| $nett_total = $this->get_nett_order($order_id, $order, $order_total); | |
| $profit_data_custom = array( | |
| 'user_id' => $setup['user'], | |
| 'unpaid_commission' => $nett_total, | |
| 'user-name' => $setup['user']->display_name, | |
| 'user-email' => $setup['user']->user_email, | |
| 'user-phone' => $setup['user']->meta->phone, | |
| 'nama_produk' => $order['product']->post_title, | |
| 'nama_pembeli' => $order['user']->display_name, | |
| 'email_pembeli' => $order['user']->data->user_email, | |
| 'wa_pembeli' => $order['user']->meta->phone, | |
| ); | |
| do_action('sejoli/notification/jv/profit/custom', $profit_data_custom); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment