Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uhlhosting/451c15ed2a0a2bebf69cd4142773d1c5 to your computer and use it in GitHub Desktop.
Save uhlhosting/451c15ed2a0a2bebf69cd4142773d1c5 to your computer and use it in GitHub Desktop.
add_action('woocommerce_thankyou_bacs', 'wpd_qr_code', 10, 1 );
function wpd_qr_code( $order_id ) {
$order = wc_get_order( $order_id );
$bacs_info = get_option( 'woocommerce_bacs_accounts');
echo "<div style='display: grid; grid-template-columns: auto auto auto;'>";
foreach ($bacs_info as $info ) {
$account = explode( "/", $info['account_number']) ? explode( "/", $bacs_info[0]['account_number']) : null ;
if (! $account) {
return;
}
$currency = $info['account_name'];
$bank_name = $info['bank_name'];
$account_number = $account[0] ;
$bank_code = $account[1];
$amount = $order->get_total();
$variable_symbol = $order->get_id();
$message = get_bloginfo('name');
echo '<div style="margin-bottom: 30px;">';
echo '<h3>';
echo $currency;
echo '</h3>';
echo '<h4>';
echo $account_number;
echo '</h4>';
echo '<h5>';
echo $bank_name;
echo '</h5>';
echo '<img src="//api.paylibo.com/paylibo/generator/czech/image?accountNumber=' . $account_number
. '&bankCode=' . $bank_code
. '&amount=' . $amount
. '&currency=' . $currency
. '&vs=' . $variable_symbol
. '&message=' . $message . '" />';
echo '</div>';
}
echo '</div>';
}
add_action( 'woocommerce_email_after_order_table', 'wpd_qr_email', 15 );
function wpd_qr_email( $order ) {
if ($order->get_payment_method() != 'bacs') {
return;
}
$bacs_info = get_option( 'woocommerce_bacs_accounts');
$account = explode( "/", $bacs_info[0]['account_number']) ? explode( "/", $bacs_info[0]['account_number']) : null ;
if (! $account) {
return;
}
echo "<div style='display: grid; grid-template-columns: auto auto auto;'>";
foreach ($bacs_info as $info ) {
$account = explode( "/", $info['account_number']) ? explode( "/", $bacs_info[0]['account_number']) : null ;
if (! $account) {
return;
}
$currency = $info['account_name'];
$bank_name = $info['bank_name'];
$account_number = $account[0] ;
$bank_code = $account[1];
$amount = $order->get_total();
$variable_symbol = $order->get_id();
$message = get_bloginfo('name');
echo '<div style="margin-bottom: 30px;">';
echo '<h3>';
echo $currency;
echo '</h3>';
echo '<h4>';
echo $account_number;
echo '</h4>';
echo '<h5>';
echo $bank_name;
echo '</h5>';
echo '<img src="//api.paylibo.com/paylibo/generator/czech/image?accountNumber=' . $account_number
. '&bankCode=' . $bank_code
. '&amount=' . $amount
. '&currency=' . $currency
. '&vs=' . $variable_symbol
. '&message=' . $message . '" />';
echo '</div>';
}
echo '</div>';
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment