Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //change BACS fields
- //original fields from plugins/woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php
- add_filter('woocommerce_bacs_account_fields','custom_bacs_fields');
- function custom_bacs_fields() {
- global $wpdb;
- //Added by Red Lorry.
- //Get the first item in the cart.
- foreach( WC()->cart->get_cart() as $cart_item ) {
- $product_id = $cart_item['product_id'];
- //Get the product vendor based on the $product_id.
- $vendor = get_wcmp_product_vendors($product_id);
- //Get the form_id of the vendor.
- $vendor_form_id = (int)get_user_meta($vendor->id, 'wcmp_vendor_registration_form_id', true);
- //Get the vendors form meta data.
- $vendor_form_data = get_post_meta($vendor_form_id, 'wcmp_vendor_fields', true);
- }
- //Get the product vendor based on the $product_id.
- $vendor = get_wcmp_product_vendors($product_id);
- //Get the form_id of the vendor.
- $vendor_form_id = (int)get_user_meta($vendor->id, 'wcmp_vendor_registration_form_id', true);
- //Get the vendors form meta data.
- $vendor_form_data = get_post_meta($vendor_form_id, 'wcmp_vendor_fields', true);
- if ( !empty($vendor_form_data) ) {
- $account_details =
- array(
- 'account_name' => $vendor_form_data[4][value],
- 'account_number' => $vendor_form_data[5][value],
- 'sort_code' => $vendor_form_data[6][value],
- 'bank_name' => $vendor_form_data[7][value],
- 'iban' => $vendor_form_data[8][value],
- 'bic' => $vendor_form_data[9][value]
- );
- $account_fields = array(
- 'bank_name' => array(
- 'label' => 'Bank',
- 'value' => $account_details[0]['bank_name']
- ),
- 'account_name' => array(
- 'label' => 'Account Name',
- 'value' => $account_details[0]['account_name']
- ),
- 'account_number' => array(
- 'label' => __( 'Account Number', 'woocommerce' ),
- 'value' => $account_details[0]['sort_code'].' '.$account_details[0]['account_number']
- ),
- 'bic' => array(
- 'label' => __( 'BIC', 'woocommerce' ),
- 'value' => $account_details[0]['bic']
- )
- );
- return $account_fields;
- }
- }
Add Comment
Please, Sign In to add comment