-
AuthorPosts
-
October 3, 2025 at 7:59 pm #245693
Regis BrisardParticipantHello,
I’ve been exploring ways to make the plugin more flexible for developers, particularly for customizing email content and coupon formatting.
Currently, in /admin/settings.php (lines 197-198), the plugin formats the coupon code and expiration date like this:
$content = str_replace( '{coupon_code}', '<span style="font-size: x-large;">' . strtoupper( $coupon_code ) . '</span>', $content ); $content = str_replace( '{date_expires}', empty( $date_expires ) ? esc_html__( 'never expires', 'woocommerce-lucky-wheel' ) : date_i18n( 'F d, Y', ( $date_expires ) ), $content );
And in /frontend/frontend.php (lines 112-113), a similar hard-coded formatting is applied.
The date formatting (date_i18n( ‘F d, Y’, $date_expires )) does not correspond to my region’s preferred display. I would rather use date_i18n( get_option( ‘date_format’ ), $date_expires ) so that the email respects the site’s date settings.
The coupon code is wrapped in a <span style=”font-size: x-large;”> and converted to uppercase. I don’t necessarily want it in this fixed style; I want to format it myself using the email editor.
After some research, I propose introducing WordPress filters (apply_filters()) so that developers can customize these values in their theme or plugin without modifying the core plugin files. For example:
// Prepare formatted values $formatted_coupon_code = strtoupper( $coupon_code ); $formatted_date = empty( $date_expires ) ? esc_html__( 'never expires', 'woocommerce-lucky-wheel' ) : date_i18n( 'F d, Y', $date_expires ); // Apply filters for external customization $formatted_coupon_code = apply_filters( 'wlwl_format_coupon_code', $formatted_coupon_code, $coupon_code ); $formatted_date = apply_filters( 'wlwl_format_coupon_date', $formatted_date, $date_expires ); // Replace in content $content = str_replace( '{coupon_code}', $formatted_coupon_code, $content ); $content = str_replace( '{date_expires}', $formatted_date, $content );
This approach allows developers to:
Change the coupon code styling or add HTML.
Format the expiration date according to site preferences or locale.
Extend the system for other placeholders in the future ({winner_name}, {prize}, etc.) without touching plugin files.Could you consider adding this functionality in a future update? It would make the plugin much more flexible and developer-friendly.
Thank you for your attention and guidance.
Best regards,
Regis B -
AuthorPosts
You must be logged in to see replies to this topic. Click here to login or register