Skip to content

Commit

Permalink
feat: add dokan_array_after function and hook on dokan parent order c…
Browse files Browse the repository at this point in the history
…reation (#647)
  • Loading branch information
saimonh3 authored and Sabbir Ahmed committed Jul 10, 2019
1 parent 5650d5e commit f1260c7
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
2 changes: 2 additions & 0 deletions includes/class-order-manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,8 @@ function maybe_split_orders( $parent_order_id ) {
$temp = array_keys( $vendors );
$seller_id = reset( $temp );

do_action( 'dokan_create_parent_order', $parent_order, $seller_id );

// record admin commision
$admin_fee = dokan_get_admin_commission_by( $parent_order, $seller_id );
$parent_order->update_meta_data( '_dokan_admin_fee', $admin_fee );
Expand Down
29 changes: 29 additions & 0 deletions includes/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -3526,3 +3526,32 @@ function dokan_get_terms_condition_url() {

return apply_filters( 'dokan_get_terms_condition_url', get_permalink( $page_id ), $page_id );
}

/**
* Add item in specefic position of an array
*
* @since DOKAN_LITE_SINCE
*
* @param array $array
* @param int|string $position <index position or name of the key after which you want to add the new array>
* @param array $new_array
*
* @return array
*/
function dokan_array_after( $array, $position, $new_array ) {
if ( is_int( $position ) ) {
return array_merge(
array_slice( $array, 0, $position ),
$new_array,
array_slice( $array, $position )
);
}

$pos = array_search( $position, array_keys( $array ) );

return array_merge(
array_slice( $array, 0, $pos + 1 ),
$new_array,
array_slice( $array, $pos )
);
}

0 comments on commit f1260c7

Please sign in to comment.