How to show a visible "this coupon has expired" message in the print view instead of the default blank output.
When a visitor opens the print view of a coupon that is expired (or otherwise hidden), the print template does not render the coupon. By default it only outputs a hidden HTML comment noting the expiration, so the page looks blank. That default is attached to the cctor_print_no_show_coupon action — hook the same action to add your own visible message.
add_action( 'cctor_print_no_show_coupon', function ( $coupon_id, $coupon_expiration ) {
$date = is_object( $coupon_expiration )
? $coupon_expiration->get_display_expiration()
: '';
echo '<div class="cctor_coupon_container cctor-expired-notice">';
echo '<h3 class="cctor-deal">' . esc_html__( 'This coupon has expired', 'coupon-creator' ) . '</h3>';
if ( $date ) {
echo '<div class="cctor-terms">Expired on ' . esc_html( $date ) . '</div>';
}
echo '</div>';
}, 10, 2 );
The action passes the coupon ID and an expiration object; call get_display_expiration() on the object for the formatted date. Reuse the existing coupon classes (see css-reference) so your notice inherits the coupon styling, and style it further with the Custom CSS option or the cctor_filter_inline_css filter, since the print view has no theme stylesheet.
The default comment callback still runs alongside yours; if you want to replace it entirely, remove_action( 'cctor_print_no_show_coupon', 'cctor_show_no_coupon_comment', 10 ) first.