Email/Print Templates

Email / Print template functions – Requires WPPizza v3.9.3+

wppizza_template_parameters / wppizza_template_markup (functions)

query for a certain set of orders and return print or email template markup – according to template selected – for each order

example :

/*********************************************************
*	[get email or print template parameters]
*	@since 3.9.3
*	@param array of args
*		@args str ('print' or 'emails')
*		@args mixed
*		(if $type 'emails' you can use a specific id(int) or  use 'customer' or 'shop' as id value to get the template parameters for the respective recipient)
*		(if $type 'print' you can use a specific id(int) or  '' (empty string) to get the default print template set to be used for printing)
*	@return array
*********************************************************/
	$args = array(
		'type' => 'print',
		'id' => 0,
	);
	$param = wppizza_template_parameters($args);


/*********************************************************
*	[get orders - see https://docs.wp-pizza.com/developers/?section=function-wppizza_get_orders for query parameters ]
*	example here queries for one order by id
*********************************************************/
	/*
		get order formatted for a particular order id
	*/
	$args = array(
		'query'=>array(
			'order_id' => $oId ,//order id you are quering for
		),
		'format' =>array(
			'blog_options' => array('localization', 'blog_info', 'date_format', 'blog_options'),
			'sections' => true,// this should be set to true for passing on [sections] array to wppizza_template_markup args below
		)
	);
	$order = wppizza_get_orders($args);
	/*
		formatted order
		reset to get the only one there is which includes localization etc
		NOTE: if your wppizza_get_orders query might return more than one result 
		,you should NOT reset the array here but use a loop instead for the template markup
		below passing on the relevant $order and $template parameters 
	*/
	$order = reset($order['orders']);


/*********************************************************
*	[get template markup - markup for a specific order based on a selected email or print template]
*	SHOULD BE USED INSIDE A LOOP IF MORE THAN ONE RESULT
*	@since 3.9.3
*	@param array of args
*		@args array (order already formatted)
*		@args array template parameters as returned by wppizza_template_parameters
*		@args bool false to get only the content type selected in the template, true to get plaintext AND html
*	@return mixed (array|str)
*********************************************************/
	$args = array(
		'order' => $order, 
		'param' => $param, 
		'content_type' => false
	);
	$markup = wppizza_template_markup($args);

wppizza_skeleton_template_emails (function)

get *email* skeleton template (“WPPizza->Templates->eMails”) by id or shop/customer inserting content between header and footer, replacing what is normally used to display order details

example:

$id = 0; /* this could be a template id or you can use 'shop' or 'customer' to get the email template in use for email to shop or customer */
$content= 'my email content';/* string */
$markup = wppizza_skeleton_template_emails($id, $content);

/*
   $markup will now be the whole template as a string using 
   $content as the message between header and footer
*/

wppizza_skeleton_template_print (function)

get *print* skeleton template (“WPPizza->Templates->Print”) by id, inserting content between header and footer, replacing what is normally used to display order details

example:

$id = 0; /* print template id - int */
$content= 'my print content';/* string */
$markup = wppizza_skeleton_template_print($id, $content);

/*
   $markup will now be the whole template as a string using 
   $content as the message between header and footer
*/