Untitled

Run Settings
LanguagePHP
Language Version
Run Command
<?php //get_vendor_id_from_url: //Returns vendor ID from the order ID captured from the URL. //If the current page is not an order, it rejects the URL and returns -1. //If by any chance the first item of the order doesn't have a vendor assigned, returns 0. function get_vendor_id_from_url ( ) { if (strpos($_SERVER['REQUEST_URI'], "/order-received/")){ preg_match('/^.*\/order-received\/([0-9]+)\/.*/',$_SERVER['REQUEST_URI'],$order_id); $order = wc_get_order( $order_id[1] ); $author_id = 0; foreach ( $order->get_items() as $item ) { if ( $item->is_type( 'line_item' ) ) { $product = $item->get_product(); $author_id = get_post_field ( 'post_author' , $product->get_id() ); break; } } }else{ $author_id = -1; } return $author_id; } //append_personal_accounts: Adds vendor's account details when payment done. function append_personal_accounts ( $account_details) { $vendor_id = get_vendor_id_from_url(); $vendor_data = get_user_meta( $vendor_id, 'wcfmmp_profile_settings', true ); if ($vendor_data['payment']['method'] == "bank_transfer"){ $append_data = array( 'account_name' => $vendor_data['payment']['bank']['ac_name'], 'account_number' => $vendor_data['payment']['bank']['ac_number'], 'bank_name' => $vendor_data['payment']['bank']['bank_name'], 'sort_code' =>"", 'iban' =>"", 'bic' =>$vendor_data['payment']['bank']['bic'], ); array_shift($account_details); //Drops first element (the admin's dummy bank account) array_push($account_details, $append_data); } return $account_details; } add_filter( 'woocommerce_bacs_accounts', 'append_personal_accounts' ); //f:class-wc-gateway-bacs.php;l:292;
Editor Settings
Theme
Key bindings
Full width
Lines