Some basic javascript help if possible!

Soldato
Joined
6 Nov 2004
Posts
5,778
Hi guy's I don't really know how to code I just look at a piece of code make changes and if it works then fine if not then I try again - probably not the best method but has worked thus far! Although i'll probably take the time to learn some day.

Anyways I use a wordpress plugin on my website to accept online food orders called wppizza. In the backend of wordpress there is page for the plugin that has an 'Order History Page' - basically orders get polled into there and it hasa dropdown menu option to change the status of the order.

So for example - when on status 'new' it is highlighted yellow and has a ringing noise (all orders when they arrive are on 'new' status by default). When changed to status 'acknowledged' it will print the order.

I have been given a code snippet by the developer so that when I change the order status it sends an email to the customer - I have edited the code to fit my needs however I am having one gripe. I would like to send an email when the status has been changed to 'delivered'. Currently it will send an email if it is changed to any status. I have done all the other parts and it works fine except for this one part but I can't figure out what he means by his instructions - what is the code needed for it to only send an email when 'delivered' is selected on the dropdown menu?

Here is the code snippet referencing that part:

Code:
/**************************************************************************************************
*
*	[admin order history: send email to customer on status change via ajax call]
*
**************************************************************************************************/
add_action( 'wppizza_ajax_action_admin', 'wpp7811_pizza_status_change_email');
function wpp7811_pizza_status_change_email($postdata) {
	if($postdata['vars']['type']=='statusupdate'){// could also add a " && in_array($postdata['vars']['type'],array('PROCESSED','REJECTED','REFUNDED'))" to only send when status changed to those
		$status=$postdata['vars']['status'];
I have included all the code before and one line of code after the part I need to amend. The line/lines I need to amend are

Code:
if($postdata['vars']['type']=='statusupdate'){// could also add a " && in_array($postdata['vars']['type'],array('PROCESSED','REJECTED','REFUNDED'))" to only send when status changed to those

The last part is the instruction but I don't understand what i'm meant to type here I have tried a few different ways and all produce errors when trying to visit my website.

Any help would be appreciated thanks.
 
Last edited:
This is what I originally tried however this does not send an email when the status has been changed although the website still works with this code.
 
It's ok mate I've managed to get both what I wanted doing working - the plugin developer finally decided to help me! Sorry to bother you with the request.
 
This was the code used for the second part - can't take credit was the developer again! Hopefully I learn enough within the next few months to not need anyways help ha but I'm sure i'll still bother you if i'm stuck.

Code:
add_filter( 'wppizza_filter_print_order_single_item', 'myprefix_add_ingredients_items_linebreaks');
function myprefix_add_ingredients_items_linebreaks($item){
	$item['addinfo']=str_replace(', ','<br />',$item['addinfo']);	
return $item;
}
 
Back
Top Bottom