This repository has been archived on 2026-04-06. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
woo-alipay-subscriptions/inc/class-wc-alipay-subscriptions-emails.php
feibisi b0c733a63c Add Woo Alipay Subscriptions integration
Introduce a new plugin to integrate Woo Alipay with WooCommerce Subscriptions. This includes admin settings, agreement signing and callbacks, auto-debit charge logic, retry scheduling, email enhancements, and a custom payment token for Alipay agreements. The code prepares for both manual and automatic renewal flows, with hooks for agreement management and payment retries.
2025-10-04 10:43:37 +08:00

30 lines
1.1 KiB
PHP

<?php
if ( ! defined( 'ABSPATH' ) ) { exit; }
class WC_Alipay_Subscriptions_Emails {
public function __construct() {
add_action( 'woocommerce_email_before_order_table', array( $this, 'inject_email_hint' ), 5, 4 );
}
/**
* Inject a helper hint into renewal invoice emails to guide Alipay payment
* Only runs for customer renewal invoice emails.
*/
public function inject_email_hint( $order, $sent_to_admin, $plain_text, $email ) {
if ( $sent_to_admin || ! $email || empty( $email->id ) ) {
return;
}
// Only target WooCommerce Subscriptions renewal invoice email
if ( 'customer_renewal_invoice' !== $email->id ) {
return;
}
// Load configured hint
$hint = get_option( 'woo_alipay_subscriptions_email_hint', '' );
if ( ! $hint ) {
return;
}
echo '<div class="woo-alipay-subscriptions-hint" style="margin:10px 0;padding:10px;background:#f6f7f7;border-left:4px solid #1d2327;">' . wp_kses_post( wpautop( $hint ) ) . '</div>';
}
}
new WC_Alipay_Subscriptions_Emails();