Author: super_admin_v3x

Add Ingredients

Filters available in WPPizza Add Ingredients wppizza_ingredients_filter_email_styles The below filter will *only* apply to emails (as emails need style declarations to be added inline). For Print templates, use the css input in WPPizza->Templates->Print in conjunction with your browsers element inspector @param: array @return: array add_filter(‘wppizza_ingredients_filter_email_styles’, 

WPPizza Autoprint

Customisations WPPizza Autoprint Adjusting print output of selected autoprint template Your print template selected MUST be set to “Html” to be able to access the css setting Go to “Wppizza -> Templates -> Print” Locate the template you have selected to use as your autoprint 

Confirm | Reject | Notify

Filters available using WPPizza – Confirm | Reject | Notify

wppizza_crn_sms_branding

Allow “Branding”: Send some arbitrary text instead of sending a phonenumber as “Sender ID”. Be aware that this will not work if you are using 2-way or 3-way SMS settings (as the recipient would not be able to reply). Furthermore, the “Sender ID” must be alphanumeric with 11 characters maximum

@param: str
@return: str

add_filter('wppizza_crn_sms_branding', 'myprefix_crn_branding');
function myprefix_crn_branding($sms_sender_id){

	/* 
		override the sender id 
	*/
	$sms_sender_id = 'My Company';//accepts a-zA-Z0-9 and spaces. 11 chars max

return $sms_sender_id;
}

Cross-Sells

Widgets/Shortcode Cross Sells – Shortcodes / Widget settings     title=’some title’ optional string Label above Cross Sells (Omit for default as set in Wppizza->Localization->Cross Sells) max=’5′ optional integer Maximum number of x-sells results to retrieve (Omit for default as set in WPPizza->Order Settings->Cross Sells) 

Delivery By Post/Zipcode

Shortcodes If you wish to display the delivery by post/zip-code selection in a different location [wppizza_dbp] If using google maps option: displaying the *dashboard map widget* showing your orders elsewhere: Shortcode: [wppizza_dbp_map] Available attributes: orders – orders to display according to status set. default: “new,delivered”. 

Goodcom Printer

Filter examples to alter the goodcom printer output

wppizza_goodcom_printer_filter_xml_site

Using the 3 filters below as described will result in a print layout similar to this screenshot. The final layout will depend on actual order and customer values submitted.

@param: array(parameters)
@return: array(filtered parameters)

/* example : adding site url in header and add additional linebreak */
add_filter('wppizza_goodcom_printer_filter_xml_site', 'set_header');
function set_header($array){
	$array['values']['site_url']['enabled'] = true;
	$array['values']['site_url']['format_value_post'] = '\r\r';//add additional linebreak
return $array;
}
/* example : summarising important values */
/*
	the goodcom xml only allows for 8 segments, some of which are reserved
	so we use the filter below to add a pseudo segment underneath the 'site'
	parameters (even though they might or might not be displayed)
*/ 
add_filter('wppizza_goodcom_printer_filter_xml_site', 'set_custom_summary');
function set_custom_summary($array){
	
		//adding payment method 
		$array['values']['payment_method'] = array(
			'sort' => 1000,//sort order - first after everything in the site section
			'enabled' => true,//enabled (should be true else one might as well not do this anyway)
			'sKey' => 'ordervars',//section key , needs to be ordervars here
			'raw_value' => false,//using formatted value
			'align' =>'center',	//center
			'omit_label' => true,//omit label (i.e do not output Payment Method but only "Cash" or "Prepay")			
			'format_value_pre' => '------------Summary-----------\r',//add divider to first added parameter with label. total length should be 11 characters if set to bold by ending with \s\r instead of just \r (eg '\r--Summary--\s\r'), 30 chars if not . start with \r if linebreak is required above
			'format_value_post' => '\s\r',//'\s\r' to set payment_method value to bold
		);
		// pickup or delivery 
		$array['values']['order_type'] = array(
			'sort' => 1001,//sort order - second after everything in this section
			'enabled' => true,
			'sKey' => 'ordervars',
			'raw_value' => false,
			'align' =>'center',	//center
			'omit_label' => true,//omit label 			
			'format_value_pre' => '',//no pre format
			'format_value_post' => '\s\r',//set value to bold
		);				
			
		//adding payment due after site name 
		$array['values']['payment_due'] = array(
			'sort' => 1002,//sort order - third after everything in this section
			'enabled' => true,//enabled (should be true else one might as well not do this anyway)
			'sKey' => 'ordervars',//section key , needs to be ordervars here
			'new_label' => 'Due:',//change too long "Payment Due" to simple "To Pay" 
			'raw_value' => false,//set to true to us unformatted value (i.e price without currency to save space perhaps as it's bolded)
			'align' =>'center',	//center
			'omit_label' => false,//dont omit label 			
			'format_value_pre' => '',//no pre format
			'format_value_post' => '\s\r',//set value to bold
		);
		//adding customer telephone  number - make sure you have that field actually enabled on the order form or you will get php notices
		$array['values']['ctel'] = array(
			'sort' => 1003,//sort order - fourth after everything in this section
			'enabled' => true,//enabled (should be true else one might as well not do this anyway)
			'sKey' => 'customer',//section key , needs to be customer here
			'raw_value' => true,//must be true, as there is no specific value_formatted for customer vars
			'align' =>'center',	//center
			'omit_label' => false,//do not omit label 			
			'format_value_pre' => '',//no pre format
			'format_value_post' => '',//not bold
		);
		//adding total
		$array['values']['total'] = array(
			'sort' => 1004,//sort order - fifth after everything in this section
			'enabled' => true,//enabled (should be true else one might as well not do this anyway)
			'sKey' => 'summary',//section key , needs to be customer here
			'raw_value' => false,//show formatted value (i.e with currency symbol)
			'align' =>'center',	//center
			'omit_label' => false,//do not omit label 			
			'format_value_pre' => '',//no pre format
			'format_value_post' => '',//not bold
		);
	
    return $array;	
}
/* example : adding an arbitrary footer with divider */
add_filter('wppizza_goodcom_printer_filter_xml_footer', 'set_footer');
function set_footer($array){

	/* 
		display a footer, centered using spaces
		with a divider above the text
	*/
	$array['label']['enabled'] = true;
	$array['label']['localization'] = 'some arbitrary footer';
	$array['label']['align'] = array('center'=>' ', 'divider' => 'pre');//center using spaces, set center to '' to not align, 'divider' to false to omit divider, 'post' for divider below

return $array;
}

Additional Filter Examples

Filtering itemised order details: ‘wppizza_goodcom_printer_filter_xml_order’

@param: array(parameters)
@return: array(filtered parameters)

//example 1- remove prices from order items , 
//example 2- display prices unformatted (without currency symbol to perhaps save on space)
//example 3- dont display brackets around size
//example 4- dont display sizes at all (only a good idea if there is only ever 1 size )
add_filter('wppizza_goodcom_printer_filter_xml_order', 'format_order_items');
function format_order_items($array){
		
		
	//example 1 
	$array['values']['pricetotal_formatted']['enabled'] = false;
		
	//example 2 
	$array['values']['pricetotal_formatted']['enabled'] = false;
	$array['values']['pricetotal']['enabled'] = true;

	//example 3 
	$array['values']['price_label']['prefix'] = '';
	$array['values']['price_label']['suffix'] = '';

	//example 4
	$array['values']['price_label']['enabled'] = false;

    
    return $array;	
}	

 

Filtering ordervars labels: ‘wppizza_goodcom_printer_filter_xml_ordervars’

@param: array(parameters)
@return: array(filtered parameters)

//example 1- remove divider and label 
//example 2- dont center 
//example 3- center using "_" (underscore) character instead of "-"
//example 4- remove label and use defined character as divider
//example 5- set a different label
//example 6- bold label
add_filter('wppizza_goodcom_printer_filter_xml_ordervars', 'format_ordervars_label');
function format_ordervars_label($array){
		
	//example 1
	$array['label']['enabled'] = false;

	//example 2
	$array['label']['align'] = false;

	//example 3
	$array['label']['align']['center'] = '_';

	//example 4
	$array['label']['enabled'] = false;
	$array['label']['align']['center'] = '_';
	$array['label']['align']['divider'] = true;
		
	//example 5		
	$array['label']['localization'] = 'other text';		

	//example 6		
	$array['label']['format_post'] = '\s\r';		
		

    return $array;	
}	

 

Filtering ordervars values output: ‘wppizza_goodcom_printer_filter_xml_ordervars’

@param: array(parameters)
@return: array(filtered parameters)

//example 1- bold the order id 
//example 2- omit label from payment method and center value
//example 3- enable and display ipaddress before all other vars
//example 4- do not display date
//example 5- display transaction id, remove label, (bold it) and move it after order_type  
//example 6- use unformatted value (this might not always differ for all variables)
//example 7- using raw db values 
//example 8- do not display "please allolow x minutes etc etc 

add_filter('wppizza_goodcom_printer_filter_xml_ordervars', 'format_ordervars');
function format_ordervars($array){
	
	//example 1 
	$array['values']['order_id']['format_value_post'] = '\s\r';

	//example 2 
	$array['values']['payment_method']['omit_label'] = true;//simply omitting label
	$array['values']['payment_method']['align'] = 'center';//centering value
	
	//example 3 
	$array['values']['ip_address']['sort'] = 1;
	$array['values']['ip_address']['enabled'] = true;		

	//example 4 
	$array['values']['order_date']['enabled'] = false;

	//example 5 
	$array['values']['transaction_id']['sort'] = 55;//order type is 50
	$array['values']['transaction_id']['enabled'] = true;	
	$array['values']['transaction_id']['omit_label'] = true;
	$array['values']['transaction_id']['format_value_post'] = '\s\r';
	
	//example 6.1 NOT bolding , must perhaps add linebreak before if no label (depending on where it's displayed)
	$array['values']['transaction_id']['sort'] = 55;//order type is 50
	$array['values']['transaction_id']['enabled'] = true;	
	$array['values']['transaction_id']['omit_label'] = true;
	$array['values']['transaction_id']['format_value_pre'] = '\r';
	
	//example 7 
	$array['values']['order_date']['raw_value'] = true;// would display 2018-10-23 12:25:59 or similar instead of -depending on your site date/time format settings) October, 23 2018 12:25 or similar
	$array['values']['total']['raw_value'] = true;// would display 3000.95 instead of $3,000.00 (or similar, depending on locale)

	//example 8 
	$array['values']['pickup_delivery']['enabled'] = false;
				
return $array;	
}

 

Filtering (omitting some) customer information: ‘wppizza_goodcom_printer_filter_xml_customer’

@param: array(parameters)
@return: array(filtered parameters)

add_filter('wppizza_goodcom_printer_filter_xml_customer', 'format_customer_data');
function format_customer_data($array){
		
	/* omit name */		
	unset($array['values']['cname']);
	/* omit email */		
	unset($array['values']['cemail']);
	/* omit address */		
	unset($array['values']['caddress']);
	/* omit first custom  field */		
	unset($array['values']['ccustom1']);
	/* etc etc */
	
	/*
		the keys (cname, cemail etc) 
		correspond to the keys / formfields in "Wppizza->OrderForm"
		(hover your mouse over the "enabled" buttons to view the keys for each field)
		
	*/
	
    return $array;	
}	

 

Filtering (adding) SKU’s to title of each item using: ‘wppizza_goodcom_printer_filter_xml_order’

@param: array
@return: array

/* adding SKU's - if set/exist - before item title */
add_filter('wppizza_goodcom_printer_filter_xml_order', 'add_sku_to_title');
function add_sku_to_title($array){
	
	$array['values']['sku'] = array(
		'sort' => 5,//before everything else (the first naturally occurring string is 'quantity' with a priority of 10)
		'enabled' => true,//no point of setting this to anything else than true
		'type' => 'name',//left hand side (item name). use 'value' to add it to right hand side
		'prefix' => '',//if you want the sku's wrapped in brackets for example, set prefix to '(' and suffix to ')' 
		'suffix' => '',//if you want the sku's wrapped in brackets for example, set prefix to '(' and suffix to ')' 
	);


return $array;	
}

 

If your particular goodcom printer model allows for fonts to be somewhat bigger you will have fewer characters per line “to play with” and may have to adjust the maximum characters per line (for dividers etc). To do so , you can do the following (reducing the default 30 chars per line to 24 in this example)

@param: int
@return: int

add_filter('wppizza_goodcom_printer_filter_max_chars_default', 'myfilter_set_goodcom_default_maxchar');
function myfilter_set_goodcom_default_maxchar($maxchar){
	$maxchar = 24;
return $maxchar;
}

// if you also need to do the equivalent for the big/bold text of the printer (reducing the default 11 to 9 in this example)
add_filter('wppizza_goodcom_printer_filter_max_chars_bold', 'myfilter_set_goodcom_bold_maxchar');
function myfilter_set_goodcom_bold_maxchar($maxchar){
	$maxchar = 9;
return $maxchar;
}

 

Ingredients (if using the “WPPizza Add Ingredients” plugin) are simply separated by | . Use the below filter to use a different divider if you wish.

@param: str
@return: str

add_filter('wppizza_goodcom_printer_filter_ai_divider', 'my_ai_divider' );
function my_ai_divider($str){
    $str = '|';/* replace | with whatever you want to use as divider between ingredients */
return $str;
}

Google Cloudprint

Filters available using WPPizza Google Cloudprint wppizza_gcp_filter_copies Sending the second copy of an order to a different printer (id) set in the same google cloudprint account. The Number of copies in the plugin settings WPPizza->Cloudprintmust be set to 2 or more for this to have 

Pdf Invoices

CSS Declaration Examples and Filters available using WPPizza – Pdf Invoices Using your own font (this must be a truetype font – see also “Know Issues” below) To use your own font, follow the guide below: Go to “WPPizza -> Settings-> PDF Invoices” Make sure 

Gateway – Stripe

Filters/Codesnippets WPPizza -> Gateways -> Stripe

Codesnippet(s) to modify “Stripe” gateway options – namely test/live api keys in this example – depending on the user selection of a custom added dropdown formfield, in this case allowing for different stripe accounts to be targeted depending on “Shop Branches” selection by user (requires WPPizza Stripe v4.1+)

 
 

A) Register a custom “Shop Branches” dropdown formfield as per “Register Formfields” filter

@param: array
@return: array

/*
	register a dropdown field containing shop branches
*/
add_filter('wppizza_register_formfields', 'myprefix_branches_dropdown');
function myprefix_branches_dropdown($formfields){	

	/* 
		*unique* identifier for the formfield you want to add
	*/
	$unique_ident = 'shop_branch';

	/*********************************************** 
		adding a select dropdown
	***********************************************/
	$formfields[$unique_ident] = array(
		/* sort order - at which position is this field displayed */
		'sort' => 10,
		/* the unique ident  */
		'key' => $unique_ident ,
		/* label displayed for the formfield */
		'lbl' => 'some label',
		/* an array of available dropdown values*/
		'value' => array('Branch 1','Branch 2','Branch 3','Branch N'),
		/* set to select to display a select dropdown*/
		'type' => 'select',
		/* true to enable (pointless to set this to false)*/
		'enabled' => true,
		/* true to make the field required on delivery, false otherwise */
		'required' => true,
		/* true to make the field required on pickup, false otherwise */
		'required_on_pickup' => true,
		/* true to prefill with a value if it is known (will only ever do anything with 'onregister' being true as well) */
		'prefill' => false,
		/* true to make field part of the user registration values */
		'onregister' => false,
		/* true to add the value entered to the email subject  */
		'add_to_subject_line' => false,
		/* placeholder - used as initial, non-selected value  or bool false / empty */
		'placeholder' => '--Please Select--',
		/* validation as available wppizza->order form. as there can be multiple validation rules, this should be an array, 
		however as this is a select field , the rules as set below are really the only sensible setting here
		*/
		'validation' => array(
			'default' => true,
		),			
	);

return $formfields;
}

 
 

B) Set session data – via ajax – on change of dropdown value

/*
	adding javascript to footer of checkout page using 'wp_footer' action
	- updates (session) user data - via ajax - on change of dropdown field
	- results in reload of page which subsequently applies filtered options
	as per 'wppizza_gateway_stripe_filter_options' below
*/
add_action('wp_footer', 'myprefix_on_branches_change');
function myprefix_on_branches_change(){	

	/* 
		same *unique* identifier set for the formfield
	*/
	$unique_ident = 'shop_branch';

	if(wppizza_is_checkout()){
		echo"<script> 
	
			jQuery(document).ready(function($){
				
				$(document).on('change', '#".$unique_ident."', function(e){
					//add loading div 
					$('html').css({'position':'relative'});/*stretch html to make loading cover whole page */
					$('body').prepend('<div class=\"wppizza-loading\"></div>');
					$('.wppizza-ordernow').attr('disabled', 'true');/* disable send order button */
				
					jQuery.post(wppizza.ajaxurl , {action :'wppizza_json', vars:{'type':'update_userdata', 'data': $('#wppizza-send-order').serialize()}}, function(obj) {
						
						window.location.reload(true);
						
						return;
						
					},'json');
				
				});
			
			});
	
		</script>";
	
	}
}

 
 

C) Apply live/test Api keys depending on “Branch” selected

@param: array
@param: array
@param: str
@return: array

/*
	apply test/live keys 
	depending on branch selected
	Note: the 'filter_ident' parameter (identifies which function calls the filter) is only referenced here for completeness sake and will not be required in 99.9% of cases
*/
add_filter('wppizza_gateway_stripe_filter_options', 'myprefix_filter_stripe_options', 10, 3);
function myprefix_filter_stripe_options($gateway_options, $order_details, $filter_ident){	

	/* 
		same *unique* identifier set for the formfield
	*/
	$unique_ident = 'shop_branch';
	
	/*
		values branch 1
	*/
	if($order_details['customer'][$unique_ident]['value'] == 'Branch 1' ){
		/*
			set Stripe API keys as required for Branch 1
			edit as required 
		*/
		$gateway_options['LiveSecretKey'] = 'sk_live_someapikeybranch_1';
		$gateway_options['LivePublishableKey'] = 'pk_live_someapikeybranch_1';
		$gateway_options['TestSecretKey'] = 'sk_test_someapikeybranch_1';
		$gateway_options['TestPublishableKey'] = 'pk_test_someapikeybranch_1';
		$gateway_options['WebhookLiveKey'] = 'whsec_someapikeybranch_1';
		$gateway_options['WebhookTestKey'] = 'whsec_someapikeybranch_1';
		
	}
	/*
		values branch 2
	*/
	elseif($order_details['customer'][$unique_ident]['value'] == 'Branch 2' ){
		
		/*
			set Stripe API keys as required for Branch 2
			edit as required 
		*/
		$gateway_options['LiveSecretKey'] = 'sk_live_someapikeybranch_2';
		$gateway_options['LivePublishableKey'] = 'pk_live_someapikeybranch_2';
		$gateway_options['TestSecretKey'] = 'sk_test_someapikeybranch_2';
		$gateway_options['TestPublishableKey'] = 'pk_test_someapikeybranch_2';
		$gateway_options['WebhookLiveKey'] = 'whsec_someapikeybranch_2';
		$gateway_options['WebhookTestKey'] = 'whsec_someapikeybranch_2';		
		
	}
	
	/*
		... etc etc ....
	*/
	
return $gateway_options;
}

Admin Dashboard Widget

Admin Dashboard Widget(requires WPPizza v3.8+) Allows you to display the WPPizza Admin Dashboard Widget in a frontend page Note: To view the widget, a user has to be logged in and have “Order History” permissions set in “Wppizza->Access Rights”, unless the “unprotected” attribute in the