New Order Notification
By editing this file -> restropress/includes/admin/payments/payments-history.php
Starting with line 44, exactly after line <?php $payments_table->advanced_filters(); ?>
I was added these line of code in order to receive message notif and audio notif when new order arrived.
code to be added
<script>
jQuery(document).ready(function () {
var interval = setInterval(function () {
if (jQuery(".rpress_notify_audio").length) {
clearInterval(interval);
jQuery( "<div id='alert'>YOU HAVE A NEW ORDER!</br></br></br><button class='button modal button2'>SHOW ME</button></div>" ).insertAfter( ".top" );
}
}, 2000);
jQuery(function() {
jQuery(".button2").click(function() {
location.reload(true);
})
})
});
jQuery(function ($) {
if (rpress_vars.is_admin == 1 && rpress_vars.enable_order_notification == 1) {
if (typeof Notification !== "undefined") {
Notification.requestPermission()
.then(function (result) {
if (result === 'denied') {
console.log('Permission wasn\'t granted. Allow a retry.');
return;
}
if (result === 'default') {
console.log('The permission request was dismissed.');
return;
}
setInterval(function () {
$.ajax({
type: 'POST',
data: {
action: 'rpress_check_new_orders'
},
url: ajaxurl,
success: function (response) {
if (response != '0') {
if (typeof response.title === "undefined") return;
var notifyTitle = response.title;
var options = {
body: response.body,
icon: response.icon,
sound: response.sound,
};
var n = new Notification(notifyTitle, options);
n.custom_options = {
url: response.url,
}
n.onclick = function (event) {
event.preventDefault(); // prevent the browser from focusing the Notification's tab
window.open(n.custom_options.url, '_blank');
};
//add audio notify because, this property is not currently supported in any browser.
if (response.sound != '') {
var loopsound = '1' == rpress_vars.loopsound ? 'loop' : '';
$("<audio controls " + loopsound + " class='rpress_notify_audio'></audio>")
.attr({
'src': response.sound,
})
.appendTo("body");
$('.rpress_notify_audio')
.trigger("play");
}
//set time to notify is show
var time_notify = parseInt(rpress_vars.notification_duration);
if (time_notify > 0) {
time_notify = time_notify * 1000;
setTimeout(n.close.bind(n), time_notify);
}
n.onclose = function (event) {
event.preventDefault();
$('.rpress_notify_audio')
.remove();
};
}
},
complete: function () { }
});
}, 5000);
});
}
}
});
</script>
<?php $payments_table->display() ?>
</form>
<?php do_action( 'rpress_payments_page_bottom' ); ?>
</div>
<style>
#alert {
padding: 50px;
text-align: center;
background-color: #F0FFF0;
color: #ffffff;
font-size: 30px;
-webkit-animation: NAME-YOUR-ANIMATION 1s infinite; /* Safari 4+ */
-moz-animation: NAME-YOUR-ANIMATION 1s infinite; /* Fx 5+ */
-o-animation: NAME-YOUR-ANIMATION 1s infinite; /* Opera 12+ */
animation: NAME-YOUR-ANIMATION 1s infinite; /* IE 10+, Fx 29+ */
}
#close {
float:right;
display:inline-block;
padding:2px 5px;
background:transparent;
margin-top: -45px;
margin-right: -40px;
cursor: pointer;
}
@-webkit-keyframes NAME-YOUR-ANIMATION {
0%, 49% {
background-color: #FA8072;
color: #F0FFF0;
}
50%, 100% {
background-color: #F0FFF0;
color: #FA8072;
}
}
.button2 {
background-color: #008CBA !important;
color: #ffffff !important;
width: 100px;
}
</style>
-
This reply was modified 2 years, 3 months ago by yoyob40.
-
This reply was modified 2 years, 3 months ago by yoyob40.