I have a WooCommerce store in which one product can be personalized by more than one artist. Every artist have their own bank account to receive their payment; so I need the bank account that appears in the thankyou page, and in the corresponding email, be the one belonging to the chosen artist. To identify each bank account and artist, I did the next:
- I assigned a 3 character identifier using the slug for every product variation (artist).
- I also assigned the same 3 character identifier using the sort code field for every bank account in the payment gateway.
Now, I need to find which bank account have a sort code equal to the selected variation slug account_details[x]['sort_code'] = (the variation slug)
Can someone point me in the right direction? I need a loop that disables all the rows in account_details
except for the one that matches the variation slug.
I found the way to select the bank account by comparing it to a a string. To do so, I added the condition if ( $bacs_account->sort_code != 'ztc' ) { continue; }
in line 255 of the file class-wc-gateway-bacs.php
foreach ( $bacs_accounts as $bacs_account ) {
$bacs_account = (object) $bacs_account; if ( $bacs_account->sort_code != 'ztc' ) { continue; }
if ( $bacs_account->account_name ) {
$account_html .= '<h3 class="wc-bacs-bank-details-account-name">' . wp_kses_post( wp_unslash( $bacs_account->account_name ) ) . ':</h3>' . PHP_EOL;
However, I cant find the way to get the variation slug to compare it to $bacs_account->sort_code
(instead of the string). Also, I think it would be better this to be modified by the functions.php file instead of messing with the class-wc-gateway-bacs.php file.
Can someone can help me in order to do any of this?