| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
exit; |
| 4 |
} |
| 5 |
|
| 6 |
use YayMail\Utils\Helpers; |
| 7 |
|
| 8 |
if ( ! isset( $args['order'] ) || ! ( Helpers::is_woocommerce_order( $args['order'] ) ) ) { |
| 9 |
return; |
| 10 |
} |
| 11 |
$text_align = yaymail_get_text_align(); |
| 12 |
$order_instance = $args['order']; |
| 13 |
$payment_gateway = wc_get_payment_gateway_by_order( $order_instance ); |
| 14 |
$payment_instructions = ''; |
| 15 |
if ( ! empty( $payment_gateway ) ) { |
| 16 |
if ( isset( $payment_gateway->instructions ) ) { |
| 17 |
$payment_instructions = $payment_gateway->instructions; |
| 18 |
} elseif ( ! empty( $payment_gateway->get_option( 'instructions' ) ) ) { |
| 19 |
// This fix the issue with Invoice Payment in Addon Germanized |
| 20 |
$payment_instructions = $payment_gateway->get_option( 'instructions' ); |
| 21 |
} |
| 22 |
} |
| 23 |
if ( ! empty( $payment_instructions ) ) : |
| 24 |
?> |
| 25 |
|
| 26 |
<div style="color:inherit;text-align: <?php echo esc_attr( $text_align ); ?>" class="yaymail_builder_instructions"> |
| 27 |
<?php |
| 28 |
echo wp_kses_post( wpautop( wptexturize( make_clickable( $payment_instructions, 'woocommerce' ) ) ) ); |
| 29 |
?> |
| 30 |
</div> |
| 31 |
|
| 32 |
<?php |
| 33 |
endif; |
| 34 |
|
| 35 |
/* |
| 36 |
Our bank details |
| 37 |
payment: Direct bank transfer |
| 38 |
*/ |
| 39 |
$direct_bank_transfer = esc_html__( 'Direct bank transfer', 'woocommerce' ); |
| 40 |
if ( false !== $payment_gateway && ! empty( $payment_gateway->account_details ) && $direct_bank_transfer === $payment_gateway->get_method_title() ) { |
| 41 |
// Get the order country and country $locale. |
| 42 |
$country = ! empty( $order_instance->get_billing_country() ) ? $order_instance->get_billing_country() : ''; |
| 43 |
$country_locale = $payment_gateway->get_country_locale(); |
| 44 |
|
| 45 |
// Get sortcode label in the $locale array and use appropriate one. |
| 46 |
$sortcode = isset( $locale[ $country ]['sortcode']['label'] ) ? $country_locale[ $country ]['sortcode']['label'] : __( 'Sort code', 'woocommerce' ); |
| 47 |
|
| 48 |
$bacs_accounts = apply_filters( 'woocommerce_bacs_accounts', $payment_gateway->account_details, $order_instance->get_id() ); |
| 49 |
|
| 50 |
if ( ! empty( $bacs_accounts ) ) { |
| 51 |
$account_html = ''; |
| 52 |
$has_details = false; |
| 53 |
|
| 54 |
foreach ( $bacs_accounts as $bacs_account ) { |
| 55 |
$bacs_account = (object) $bacs_account; |
| 56 |
|
| 57 |
if ( $bacs_account->account_name ) { |
| 58 |
$account_html .= '<h3 style="color:inherit;font-size:16px">' . wp_kses_post( wp_unslash( $bacs_account->account_name ) ) . ':</h3>' . PHP_EOL; |
| 59 |
} |
| 60 |
|
| 61 |
$account_html .= '<ul class="yaymail-bacs-bank-details">' . PHP_EOL; |
| 62 |
|
| 63 |
// BACS account fields shown on the thanks page and in emails. |
| 64 |
$account_fields = apply_filters( |
| 65 |
'woocommerce_bacs_account_fields', |
| 66 |
[ |
| 67 |
'bank_name' => [ |
| 68 |
'label' => __( 'Bank', 'woocommerce' ), |
| 69 |
'value' => $bacs_account->bank_name, |
| 70 |
], |
| 71 |
'account_number' => [ |
| 72 |
'label' => __( 'Account number', 'woocommerce' ), |
| 73 |
'value' => $bacs_account->account_number, |
| 74 |
], |
| 75 |
'sort_code' => [ |
| 76 |
'label' => $sortcode, |
| 77 |
'value' => $bacs_account->sort_code, |
| 78 |
], |
| 79 |
'iban' => [ |
| 80 |
'label' => __( 'IBAN', 'woocommerce' ), |
| 81 |
'value' => $bacs_account->iban, |
| 82 |
], |
| 83 |
'bic' => [ |
| 84 |
'label' => __( 'BIC', 'woocommerce' ), |
| 85 |
'value' => $bacs_account->bic, |
| 86 |
], |
| 87 |
], |
| 88 |
$order_instance->get_id() |
| 89 |
); |
| 90 |
|
| 91 |
foreach ( $account_fields as $field_key => $field ) { |
| 92 |
if ( ! empty( $field['value'] ) ) { |
| 93 |
$account_html .= '<li class="' . esc_attr( $field_key ) . '">' . wp_kses_post( $field['label'] ) . ': <strong>' . wp_kses_post( wptexturize( $field['value'] ) ) . '</strong></li>' . PHP_EOL; |
| 94 |
$has_details = true; |
| 95 |
} |
| 96 |
} |
| 97 |
|
| 98 |
$account_html .= '</ul>'; |
| 99 |
}//end foreach |
| 100 |
|
| 101 |
if ( $has_details ) { |
| 102 |
$account_html = PHP_EOL . $account_html; |
| 103 |
echo wp_kses_post( "<section class='yaymail-builder-wrap-account'> $account_html </section>" ); |
| 104 |
} |
| 105 |
}//end if |
| 106 |
}//end if |
| 107 |
?> |
| 108 |
|