add_action( ‘init’, ‘auto_redeem_coupon’ );
function auto_redeem_coupon() {
if ( isset( $_GET[‘redeem_coupon’] ) ) {
$coupon_code = sanitize_text_field( $_GET[‘redeem_coupon’] );
// Get the WooCommerce coupon
$coupon = new WC_Coupon( $coupon_code );
if ( $coupon->get_id() ) {
// Check if coupon exists
if ( function_exists( 'mycred_add' ) ) {
$user_id = get_current_user_id();
if ($user_id > 0) { // Ensure the user is logged in
// Get coupon discount amount as points
$points = $coupon->get_amount();
// Check if user has already redeemed the coupon
$redeemed = get_user_meta($user_id, '_redeemed_' . $coupon_code, true);
if (!$redeemed) {
mycred_add(
'reward_points', // Point type as defined in MyCred
$user_id,
$points,
'Points earned on coupon redemption',
''
);
// Mark the coupon as redeemed for this user
update_user_meta($user_id, '_redeemed_' . $coupon_code, true);
// Display a success message
add_action( 'wp_footer', function() use ($points) {
echo '<div style="background: #d4edda; color: #155724; padding: 10px; margin: 10px 0; border: 1px solid #c3e6cb; border-radius: 5px;">Your coupon has been successfully redeemed, and you have earned ' . $points . ' points!</div>';
});
} else {
// Display an error message
add_action( 'wp_footer', 'display_error_message' );
}
} else {
// Redirect user to login page
wp_redirect( wp_login_url( home_url( '/redeem-coupon/?redeem_coupon=' . $coupon_code ) ) ); // Redirect to login page
exit;
}
}
}
}
}
function display_error_message() {
echo ‘
This coupon has already been redeemed.’;
}
This snippet automatically redeems a WooCommerce coupon code via a direct URL. I generate a QR code from this URL, and I have set up a QR code scanner on my website. When the QR code is scanned, it automatically redirects to the URL, and the coupon code is redeemed, awarding points to the user. I use the MyCred plugin for points.
However, I want to modify this setup so that instead of including the entire URL in the QR code, I generate QR codes that only contain the coupon code. Then, the QR code scanner should read only the coupon code and redeem it automatically without needing to include a URL.
rihgt now i’m using this type url for coupon redeeming function
https://domain.com/redeem-coupon/?redeem_coupon=J26WC5QR
Hi,
Are you guys giving support to the plugin? I see there hasnt been an update for almost two years.
]]>Hello,
Is there a parameter I can use to have a bigger scanner button, please ? Just like with the QR code generator.
Thanks for your answer, I love your plugin.
Best,
]]>I installed the plugin few months ago. It was working well. Now while I was updating the site, I found that the plugin is not working. I am using ‘Button’ widget in elementor to redirect and open the scanner. But even after assigning the class “qr-scanner-redirect-open”, the button is not opening the scanner. Is it possible that the plugin is not compatible with latest WordPress or Elementor version
]]>Seems to be broken, no longer scans all the time and says screen recording on on Dynamic island on Apple iPhone 14 Pro Max. Please update ??
Screen recording makes user anxious the website is recording their on-screen behaviour, once you scan an item, its does not seem to scan anything else.
Hi,
I appretiate your work in this plugin…outstanding. I even gone ahead to use it in my android web app. You see when the website (with qr scanner plugin installed) is converted into an android app, android runtime permissions must be implemented. The plugin also has its own permissions workflow and dialog boxes which in my case are delaying android runtime permissions. The result is a long chain of permission requests that end up confusing. Are you available for this discussion, or do you have a quick fix for this. I can’t find your email anywhere, but I really would have loved to contact you directly for this.
Thanks
]]>hello, can we add a button to authorize access to the camera instead of the dialog box? The dialog box asking for permission to access just doesn’t show up in “normal browsing” yet it does in “private browsing”. The only message that appears in normal mode for me is “permission failed”.
]]>There’s a way to scan multiple Qr Code (for example in the same ticket) without closing the X icon on the right and reopen it for each CODE?It can be a great improvement..
Your plugin it’s perfect but we need to have a more fast checkin process.
Let me know and thanks for your amazing job!
Hi,
When your plugin is activated there is a diplay issue in wordpress backend as you can see here https://prnt.sc/O4V3q0-IE8b4 – https://prnt.sc/UZs7PkVetYxd – https://prnt.sc/CdM1ouONWCYW
When i deactivate it everything looks normal.
Are guys keep supporting this plugin? I really like it and i really need it for my online store.
Thanks!
]]>I could totally believe I’m not deploying/configuring this correctly, but the plugin seems to be installed properly, and I’ve tried using all the implementation methods on my linked page.
The shortcode version [qr-scanner-redirect] reveals a Minified React Error. Open via function claims that window.qrscannerredirect.open isn’t a function.
Anybody having success with this lately? Do I need to confirm a JS version on WordPress?
Thanks!
]]>Hi guys and thanks for the amazing plugin..it does exactly what it is supposed to do.
Unfurtunally it create a conflict with Wp Backery backend editor.The edit windows stop working on the entire website if your plugin it’s activated.
For now i switch on and off your plugin when i need to edit something but it can be great if there’s a fix for this (or you plan to take a look at it).
I’m really open to give you access to my staging site if you need.
Let me know and keep doing your amazing work!
Best
I would like the scan to only accept sites from my domain, when scanning a qr that is not related to my domain it throws an error or a message.
Great plugin, thanks for your support
]]>I can’t get it to generate the qr, I put the shortcode [qr-generator id = “1” size = “300” json-options = ‘{}’] but it doesn’t show anything, you can help me by indicating how to do it correctly.
I use the elementor constructor.
Great plugin, thanks for your support
]]>Hellp,how can I change the scanner icon with another image?
]]>Hello,
all looks good, but language settings are not possible to save. I click to save button and again I have your default settings instead of mine. ??
Pls check this
Thank you very much!
Tom
Hello dear Author, thank you for this Amazing Plugin.
it is exactly what we looking for.
however, we have are not that techie to understand how to bind the open scanner function to a Elementor Pro (pagebuilder) Button.
There is a chance you can guide us thru it? or have any advice how to do it.
we already added the class to the button but clicking the button results in no action.
Best regards
Patrick
I recently started using the QR Scanner Redirect on four pages. I’m using the shortcode; [qr-scanner-redirect]
However, there are three identical messages in the admin area. The message is as follows;
Warning: Use of undefined constant QSR_SHORTCODE_NAME – assumed ‘QSR-SHORTCODE-NAME’ (this will throw an error in a future version of PHP) in /home/****/domains/*****/public_html/wp-content/plugins/qr-scanner-redirect/include/metaboxes.php on line 26
Any idea how to fix this?
]]>I can’t get it to generate the qr, I put the shortcode [qr-generator id = “1” size = “300” json-options = ‘{}’] but it doesn’t show anything, you can help me by indicating how to do it correctly.
I would also like to know how to use the json file that is generated in the style page.
I use the elementor constructor.
Great plugin, thanks for your support
]]>Hi,
We have a organic farm and would like to use QR codes to identify plants.
Our idea would be:
In our garden people can look and taste plants. So at every plant we would like to have a QR code available.
That way the customer can use our website (with a QR code scanner) to scan the QR codes.
Then they will be redirected to the specific page of that plant. So just a QR with a URL.
Is there any possibility that we can use your plugin for that? Or do you have a better idea?
Kind Regards,
Robby
]]>Hello,
We found your plugin really helpful.
We would love it if you add some more customization options to it.
Also want know if there is option to open the link into the new tab, if yes please guide to modify it.
Thanks & Regards,
BIZNESS SHELTER
Hello. Plugin couses problem with WPBakery in Frontend editor. In classic mode all looks good. When I set Frontend mode so content attaches right side screen like a sidebar into narrow element. This is grate plugin otherwise, I really like it. I would be very thankful if you solve that problem.
Best regards
]]>Hello,
Can you enable strings for translations? We would like to help ??
Thank you
EL TRABAJA CON EL BOTON PARA ACTIVAR EL SCANNER, PERO LE ESTOY PONIENDO MI PROPIO BOTON
<button class=”qrscannerredirect-open”>QR SCANNER</button> Y NO LO ACTIVA, ESTO ME OCURRIO CUANDO ACTUALICE EL PLUGIN, EN OTRA PAGINA CON LA VERSION ANTERIOR SI ESTA FUNCIONANDO Y NO QUIERO ACTUALIZAR EL PLUGIN PORQUE ME DA MIEDO QUE OCURRA LO MISMO Y LA PAGINA SE UTILIZA EN UN PROYECTO.
Hello,
Does it works in mobile browsers?
great initiative, a very useful plugin
but there is an error, how can I solve it?
Catchable fatal error: Argument 1 passed to QSR_Tabs::__construct() must be an instance of string, string given, called in /wp-content/plugins/qr-scanner-redirect/index.php on line 24 and defined in /wp-content/plugins/qr-scanner-redirect/class/tabs.class.php on line 19
]]>Hello,
your plugin works pretty well. A few problem appear when I test it:
– after activation a error message was generated:
constant UPLOAD_IMAGE_PREFIX – assumed ‘UPLOAD_IMAGE_PREFIX’ (this will throw an Error in a future version of PHP) in /home/ovkvarna/public_html/new/wp-content/plugins/qr-scanner-redirect/index.php on line 19
– in settings page – whatever change I do they are not saved
– icon for plugin settings does not appear in admin menu
Wish you all the best and thank you for good work
]]>