How to change the counter's number format, align it, and understand where it displays.
The counter shows how many times a coupon has been viewed and can hide the coupon once a limit is reached. Enable it per coupon on the Expiration / Counter tab (cctor_counter_activate), and set Counter Display to Show (cctor_counter_show) to render it under the coupon on the single/print view. See Coupon Counter for the basics and Pro Custom Fields for the meta keys.
Show a single number instead of "1 of 20" #
Set Activate Counter to Activate Unlimited Counter. In this mode the output is just the running view count (%d) with no limit, instead of %d of %d.
If you want to keep the limit enforced but still display only the current number, override the counter string with a gettext context filter. The counter text is registered with the context counter views in the coupon-creator-pro text domain:
add_filter( 'gettext_with_context', function ( $translation, $text, $context, $domain ) {
if ( 'coupon-creator-pro' === $domain && 'counter views' === $context && '%d of %d' === $text ) {
return '%1$d'; // show only the current count; the limit still applies
}
return $translation;
}, 10, 4 );
Align the counter #
The counter renders inside a .coupon-counter div (unlimited/legacy display) or a .cctor-expiration block with the counter / expiration-counter class. Add CSS in your theme:
.coupon-counter,
.cctor-expiration.counter {
text-align: center;
}
When both an expiration date and a counter show together, they split into .cctor-col.cctor-one-half columns (.coupon-text-left and .coupon-text-right) — target those to change that split.
Where the counter displays #
By design in 3.6.0 the counter renders on the single coupon and print view only (the display code is guarded by is_singular( 'cctor_coupon' )), not in the shortcode loop. A view is counted once per single/print load.
For multi-print contexts, the check for whether the current request is a single-coupon view is filterable, which controls whether that load increments the count:
/**
* @param bool $is_single_coupon
* @param Cctor__Coupon__Pro__Expiration $expiration
*/
add_filter( 'cctor_pro_expiration_counter_singular_coupon_check', function ( $is_single_coupon, $expiration ) {
return $is_single_coupon;
}, 10, 2 );