Untitled

mail@pastecode.io avatar
unknown
plain_text
a month ago
904 B
2
Indexable
Never
add_filter('woocommerce_bacs_accounts', function($account_details, $order_id){
	$vendors = marketking()->get_vendors_of_order($order_id);

	// check that there is at least 1 vendor
	$has_vendor = false;
	$has_admin = false;
	foreach ($vendors as $vendor){
		if (marketking()->is_vendor($vendor)){
			$has_vendor = true;
		}
		if ($vendor == 1){
			$has_admin = true;
		}
	}

	if (!$has_admin){
		// overwrite account details setting
		$account_details = array();
	}

	if ($has_vendor){
		foreach ($vendors as $vendor){
			// get bank account details
			// what if not set?
			$vendor_account = array(
				'account_name' => 'Vendor Walmart ($15.13 total)',
				'account_number' => 'IBAN1234',
				'bank_name' => 'BANK ZZZ',
				'sort_code' => '455667',
				'iban' => 'IBAN345',
				'bic' => 'INGBROUB',

			);

			array_push($account_details, $vendor_account);
		}
	}

	return $account_details;
}, 10, 2);
Leave a Comment