Guest User

Untitled

a guest
Dec 12th, 2017
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. //change BACS fields
  2. //original fields from plugins/woocommerce/includes/gateways/bacs/class-wc-gateway-bacs.php
  3. add_filter('woocommerce_bacs_account_fields','custom_bacs_fields');
  4. function custom_bacs_fields() {
  5. global $wpdb;
  6.  
  7. //Added by Red Lorry.
  8. //Get the first item in the cart.
  9. foreach( WC()->cart->get_cart() as $cart_item ) {
  10. $product_id = $cart_item['product_id'];
  11. //Get the product vendor based on the $product_id.
  12. $vendor = get_wcmp_product_vendors($product_id);
  13. //Get the form_id of the vendor.
  14. $vendor_form_id = (int)get_user_meta($vendor->id, 'wcmp_vendor_registration_form_id', true);
  15. //Get the vendors form meta data.
  16. $vendor_form_data = get_post_meta($vendor_form_id, 'wcmp_vendor_fields', true);
  17. }
  18. //Get the product vendor based on the $product_id.
  19. $vendor = get_wcmp_product_vendors($product_id);
  20. //Get the form_id of the vendor.
  21. $vendor_form_id = (int)get_user_meta($vendor->id, 'wcmp_vendor_registration_form_id', true);
  22. //Get the vendors form meta data.
  23. $vendor_form_data = get_post_meta($vendor_form_id, 'wcmp_vendor_fields', true);
  24. if ( !empty($vendor_form_data) ) {
  25. $account_details =
  26. array(
  27. 'account_name' => $vendor_form_data[4][value],
  28. 'account_number' => $vendor_form_data[5][value],
  29. 'sort_code' => $vendor_form_data[6][value],
  30. 'bank_name' => $vendor_form_data[7][value],
  31. 'iban' => $vendor_form_data[8][value],
  32. 'bic' => $vendor_form_data[9][value]
  33. );
  34. $account_fields = array(
  35. 'bank_name' => array(
  36. 'label' => 'Bank',
  37. 'value' => $account_details[0]['bank_name']
  38. ),
  39. 'account_name' => array(
  40. 'label' => 'Account Name',
  41. 'value' => $account_details[0]['account_name']
  42. ),
  43. 'account_number' => array(
  44. 'label' => __( 'Account Number', 'woocommerce' ),
  45. 'value' => $account_details[0]['sort_code'].' '.$account_details[0]['account_number']
  46. ),
  47. 'bic' => array(
  48. 'label' => __( 'BIC', 'woocommerce' ),
  49. 'value' => $account_details[0]['bic']
  50. )
  51. );
  52. return $account_fields;
  53. }
  54. }
Add Comment
Please, Sign In to add comment