Jump to content

Archived

This topic is now archived and is closed to further replies.

darrenultra

Beep when order status is updated.

Recommended Posts

Hey,

 

I'm trying to make my orders.php page beep when the status of an order is successfuly updated.

 

 

if ($order_updated == true) {

 

// Start my beep code

?>

<audio autoplay="autoplay" style="display:none" src="tada.wav" controls preload="auto" autobuffer></audio>

<?php

// End my beep code

 

$messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');

} else {

$messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');

}

 

Unfortunately my page will not beep. In fact no code that I place below if ($order_updated == true) { seems to get executed. For example if I try 'echo "insert beep here";' this text will not display next to the text which notifies me that my order has been successfuly updated.

 

Can anyone explain what I might be doing wrong and offer a solution?

Share this post


Link to post
Share on other sites

I think theres just not enough time for your beep to even load. Once you hit the update button, your took back to the orders table instantly. What you probably would need to do is register a session variable, and if its set, play the beep.


Follow the community build:

BS3 to osCommerce Responsive from the Get Go!

Check out the new construction:

Admin Gone to Total BS!

Share this post


Link to post
Share on other sites

Hey,

 

Thanks for your help.

 

Just to clarify, any code inserted in this position does not get executed. For example if I do the following:

 

 

if ($order_updated == true) {

 

// Start my beep code

echo "beep text";

// End my beep code

 

$messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');

} else {

$messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');

}

 

then the words 'beep text' do not get displayed next to the messagestack text.

 

I don't suppose you can give me any pointers to help me save the beep noise to a session variable?

 

Thanks

Share this post


Link to post
Share on other sites

I'm not sure a simple echo is going to show up in the message stack. You could tell for sure by putting it ahead of the "if" test and see if it's then visible.

 

Is $order_updated visible in your function, and does it have a value? You might have to do a globals $order_updated; at the top of the function to have its value available, if it's defined outside the function. Are you sure that it ever goes 'true'? BTW, "if ($order_updated == true)" can be simplified to "if ($order_updated)".

Share this post


Link to post
Share on other sites

define('SUCCESS_ORDER_UPDATED_BEEP', 'Success: beep text.');

 

$messageStack->add_session(SUCCESS_ORDER_UPDATED, 'success');

$messageStack->add_session(SUCCESS_ORDER_UPDATED_BEEP, 'success');

} else {

$messageStack->add_session(WARNING_ORDER_NOT_UPDATED, 'warning');

}

Share this post


Link to post
Share on other sites

you can also run a javascript to check if your current page contains the class="messageStackSuccess"

 

If the page find this AFTER it is loaded ... run a javascript function that autoplay your beep.

 


   $(document).ready(function() {

var MyBeep = $( "body" ).find( ".messageStackSuccess" );
if (MyBeep.length > 0) {
alert('beep');
}else{
alert('NO beep');
}
   });

Share this post


Link to post
Share on other sites

×