[2 lines collapsed]
* Plugin Name: SBI ePay for WooCommerce
* Plugin URI: https://icariivr.org.in
* Description: SBI ePay payment gateway + India Post order tracking (admin form, customer My Account).
* Version: 1.4.13
* Version: 1.4.14
* Author: ICAR IIVR
* Text Domain: sbi-epay-woocommerce
* Requires at least: 5.0
* Requires PHP: 8.2
* WC requires at least: 4.0
* WC tested up to: 8.x
*/
defined('ABSPATH') || exit;
if (!defined('SBI_EPAY_VERSION')) {
define('SBI_EPAY_VERSION', '1.4.13');
define('SBI_EPAY_VERSION', '1.4.14');
}
/**
[339 lines collapsed]
$order->delete_meta_data('_sbi_invoice_attachment_mime');
$order->delete_meta_data('_sbi_invoice_customer_sent');
$order->delete_meta_data('_sbi_invoice_manager_sent');
$order->delete_meta_data('_sbi_order_confirm_customer_sent');
$order->delete_meta_data('_sbi_order_confirm_manager_sent');
$order->save();
if ($attach !== '' && is_file($attach)) {
[113 lines collapsed]
}
function sbi_epay_build_invoice_html($order, $invoice_number, $for_pdf = false) {
$logo_src = sbi_epay_invoice_logo_src_for_pdf();
// Base64 logo only in PDF — embedding it in HTML email can stall SMTP and block other order mail.
$logo_src = $for_pdf ? sbi_epay_invoice_logo_src_for_pdf() : '';
if ($logo_src === '' && !$for_pdf) {
$logo_file = plugin_dir_path(__FILE__) . 'assets/icar-logo.png';
if (is_readable($logo_file)) {
$logo_src = plugins_url('assets/icar-logo.png', __FILE__);
}
}
$logo_block = $logo_src !== ''
? ''
: '';
[9 lines collapsed]
$payment_title = $order->get_payment_method_title();
$payment_label = $payment_title !== '' ? $payment_title : 'SBIePay';
$billing_html = sbi_epay_invoice_format_address_html($order, 'billing');
$billing_html = function_exists('sbi_epay_invoice_format_address_html')
? sbi_epay_invoice_format_address_html($order, 'billing')
: wp_kses_post($order->get_formatted_billing_address());
if ($billing_html === '') {
$billing_html = esc_html__('—', 'sbi-epay-woocommerce');
}
$shipping_html = sbi_epay_invoice_format_address_html($order, 'shipping');
$shipping_html = function_exists('sbi_epay_invoice_format_address_html')
? sbi_epay_invoice_format_address_html($order, 'shipping')
: wp_kses_post($order->get_formatted_shipping_address());
// Always print a shipping block: use shipping address, else fall back to billing.
if ($shipping_html === '') {
$shipping_html = $billing_html;
[257 lines collapsed]
return array($html_path, 'text/html');
}
function sbi_epay_mail_invoice_if_needed($order_id, $force_resend = false) {
/**
* Lightweight paid-order confirmation (no PDF). Sent before invoice so a Dompdf/SMTP
* failure cannot swallow shop + customer order mail.
*
* @param int $order_id Order ID.
* @param bool $force Resend even if already marked sent.
* @return bool True if at least one confirmation mail was attempted successfully.
*/
function sbi_epay_send_paid_order_confirmations($order_id, $force = false) {
if (!function_exists('wc_get_order')) {
return;
return false;
}
$order = wc_get_order($order_id);
if (!$order || !is_a($order, 'WC_Order') || !sbi_epay_order_qualifies_for_invoice($order)) {
return;
return false;
}
if ($force_resend) {
$order->delete_meta_data('_sbi_invoice_customer_sent');
$order->delete_meta_data('_sbi_invoice_manager_sent');
$order->save();
}
list($attach_path, $mime) = sbi_epay_generate_invoice_attachment($order, $force_resend);
if ($attach_path === '' || !is_readable($attach_path)) {
$order->add_order_note(__('SBI ePay: Invoice file could not be created. Check uploads folder permissions or Dompdf vendor/.', 'sbi-epay-woocommerce'));
$order->save();
return;
}
$invoice_number = absint($order->get_meta('_sbi_invoice_number', true));
$any_ok = false;
$headers = sbi_epay_mail_headers();
$use_html_inline = ($mime === 'text/html' || preg_match('/\.html$/i', $attach_path));
$attachments = $use_html_inline ? array() : array($attach_path);
$customer_email = sanitize_email($order->get_billing_email());
if (is_email($customer_email) && ($force_resend || !$order->get_meta('_sbi_invoice_customer_sent', true))) {
if (is_email($customer_email) && ($force || !$order->get_meta('_sbi_order_confirm_customer_sent', true))) {
$subject = sprintf(
/* translators: 1: invoice number, 2: order number */
__('Invoice #%1$s for order #%2$s – ICAR-IIVR Seed Portal', 'sbi-epay-woocommerce'),
$invoice_number,
/* translators: %s: order number */
__('Order confirmation #%s – ICAR-IIVR Seed Portal', 'sbi-epay-woocommerce'),
$order->get_order_number()
);
if ($use_html_inline) {
$intro = '
' . sprintf( /* translators: %s: customer first name */ esc_html__('Hello %s,', 'sbi-epay-woocommerce'), esc_html($order->get_billing_first_name() ?: __('Customer', 'sbi-epay-woocommerce')) ) . '
' . '' . esc_html__('Your invoice is shown below. Thank you for your order. You can print this email or save it as a PDF from your mail program if you need a file copy.', 'sbi-epay-woocommerce') . '
'; $body = $intro . '' . sprintf( /* translators: %s: customer first name */ esc_html__('Hello %s,', 'sbi-epay-woocommerce'), esc_html($order->get_billing_first_name() ?: __('Customer', 'sbi-epay-woocommerce')) ) . '
' . '' . esc_html__('Please find your invoice attached. Thank you for your order.', 'sbi-epay-woocommerce') . '
'; $lines = ''; foreach ($order->get_items() as $item) { $qty = (float) $item->get_quantity(); $lines .= '' . sprintf( /* translators: %s: customer first name */ esc_html__('Hello %s,', 'sbi-epay-woocommerce'), esc_html($order->get_billing_first_name() ?: __('Customer', 'sbi-epay-woocommerce')) ) . '
'; $body .= '' . esc_html__('Thank you. We have received your paid order. This is your confirmation.', 'sbi-epay-woocommerce') . '
'; $body .= '' . esc_html__('Order:', 'sbi-epay-woocommerce') . ' #' . esc_html($order->get_order_number()) . '
';
$body .= '' . esc_html__('Total:', 'sbi-epay-woocommerce') . ' ' . esc_html(wp_strip_all_tags($order->get_formatted_order_total())) . '
' . esc_html__('Items:', 'sbi-epay-woocommerce') . '
' . esc_html__('Your invoice is sent in a separate email.', 'sbi-epay-woocommerce') . '
'; $body .= '