joshpa87
Forum Replies Created
Viewing 2 replies - 1 through 2 (of 2 total)
-
Forum: Plugins
In reply to: [Discount Rules for WooCommerce] Plugin became case sensitive?Thank you, the new version seems to have resolved the issue. Appreciate you and your team acting so quickly.
- This reply was modified 12 months ago by joshpa87.
Forum: Plugins
In reply to: [Discount Rules for WooCommerce] Plugin became case sensitive?For those relying on this plugin – while we wait for an update here is some code I am using to help mitigate the issue:
If you’re using URL coupons, this first snippet will check the url for a coupon, convert it lowercase and add a banner asking the customer to enter the code manually.
This code can be added sitewide, by using a code snippet plugin like WP CODE.
<script>
document.addEventListener('DOMContentLoaded', function () {
const urlParams = new URLSearchParams(window.location.search);
let couponParam = urlParams.get('wdr_coupon');
if (couponParam) {
couponParam = couponParam.toLowerCase(); // convert to lowercase
const banner = document.createElement('div');
banner.id = 'wdr-coupon-banner';
banner.style.cssText = 'background:#f00;padding:15px;border-bottom:1px solid #ccc;text-align:center;font-size:16px;position:fixed;top:0;width:100%;z-index:99999999;color:#ffffff';
banner.innerHTML =<br> <span>Enter your coupon code: <span style="background:#000000; color:#ffffff; padding: 5px 10px; border-radius:5px;margin-right:5px; margin-left:5px"><strong>${couponParam}</strong></span> in the cart or checkout to apply your discount!</span><br> <button id="dismiss-wdr-banner" style="margin-left:15px;padding:5px 10px; background:#ffffff; color: #000000">Dismiss</button><br>;
document.body.prepend(banner);
document.body.style.marginTop = '60px';
document.getElementById('dismiss-wdr-banner').addEventListener('click', function () {
banner.remove();
document.body.style.marginTop = '0';
});
}
});
</script>For people entering codes manually, this second Snippet changes the coupon error message and asks the customer to enter their coupon in lowercase. It needs to be added to your functions.php file.
function coupon_error_message_change($err, $err_code, $WC_Coupon) {
switch ( $err_code ) {
case $WC_Coupon::E_WC_COUPON_NOT_EXIST:
$err = "Error, please try entering your coupon code using all lowercase letters. Eg: 'coupon'";
}
return $err;
}
add_filter( 'woocommerce_coupon_error','coupon_error_message_change',10,3 );Cheers.
- This reply was modified 12 months ago by joshpa87. Reason: code fix
Viewing 2 replies - 1 through 2 (of 2 total)