WPPizza Documentation https://docs.wp-pizza.com documentation for the wordpress wppizza plugin (version 3.x) Fri, 18 Jul 2025 17:42:28 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.3 Set Pickup/Delivery using link https://docs.wp-pizza.com/set-pickup-delivery-using-link/ Mon, 16 Dec 2024 18:05:30 +0000 https://docs.wp-pizza.com/?p=514 …]]> Adding a _GET parameter to any link to set user option to be pickup or delivery (Requires WPPizza v3.19.3+)

This will only work if

  • – your delivery options are not set to “No delivery offered / pickup only”
  • – have “Allow order pickup by customer” enabled (WPPizza -> Order Settings)
  • – enabled this functionality generally in WPPizza -> Order Settings : Global

example:

/**********************************************************
	add  ?delivery or ?pickup parameter to a link 
	something like 
**********************************************************/
<a href="http[s]://[my-domain.com]/?pickup">Some link text </a> /* set to pickup */
<a href="http[s]://[my-domain.com]/?delivery">Some link text</a> /* set to delivery*/
<a href="http[s]://[my-domain.com]/?foo=1&bar=2&pickup">Some link text</a> /* set to pickup */
<a href="http[s]://[my-domain.com]/?foo=1&bar=2&delivery">Some link text</a> /* set to delivery*/
<a href="http[s]://[my-domain.com]/?foo=1&bar=2&pickup">Some link text</a> /* set to pickup */
<a href="http[s]://[my-domain.com]/?foo=1&bar=2&delivery">Some link text</a> /* set to delivery*/
<a href="http[s]://[my-domain.com]/?foo=1&bar=2&pickup=1">Some link text</a> /* set to pickup */
<a href="http[s]://[my-domain.com]/?foo=1&bar=2&delivery=1">Some link text</a> /* set to delivery*/
...etc...

If the “pickup” and or “delivery” parameter is already being used elsewhere, you can change this by using a constant like so in your wp-config.php:

define('WPPIZZA_GET_DELIVERY', 'x4delivery');
define('WPPIZZA_GET_PICKUP', 'x4pickup');

in which case the links above would then need to be

&x4delivery
&x4pickup

respectively

]]>
Update prices in bulk https://docs.wp-pizza.com/update-prices-in-bulk/ Thu, 04 Jan 2024 17:10:42 +0000 https://docs.wp-pizza.com/?p=508 …]]> Update WPPizza menu item prices in bulk , adding 10% to all prices (change values as required)

example function myprefix_update_wppizza_prices:

/*	
 IMPORTANT: RUN THIS ONE TIME ONLY AND DELETE/DISABLE THIS SCRIPT AGAIN WHEN YOU ARE DONE OR YOU WILL CONTINUALLY BE ADDING 10% ON TOP OF 10%
 YOU COULD ALSO ADD AN ADDITIONAL META DATA FLAG PERHAPS TO MAKE SURE IT ONLY GETS UPDATED IF THIS FLAG IS NOT SET YET, BUT I LEAVE THIS
 UP TO THE YOU AS TO HOW OR IF YOU WANT TO DO THAT .
 IN ANY EVENT: I STRONGLY SUGGEST YOU MAKE A BACKUP FIRST AND - AS ALWAYS - USE AT YOUR OWN RISK
*/
/* script must be run on init or later or things will not work */
add_action( 'init', 'myprefix_update_wppizza_prices');
function myprefix_update_wppizza_prices(){
	
	/* 
		the percentage to add to all prices 
		change as required
	*/
	$percent = 10;

	/*
		conditionals: only runs if
		- logged into WP admin
		- logged in user has 'wppizza_cap_menu_items' capabilities
		- the _GET['runonce'] parameter is set (so as to only run it one time , see above)
	*/
	if( is_admin() && current_user_can('wppizza_cap_menu_items') && isset($_GET['runonce'])){
		
		//print info
		print"------------ START UPDATING WPPIZZA ITEMS PRICES  --------------
".PHP_EOL; //wppizza post type $postType = 'wppizza'; //get all wppizza menu items $menuItems = get_posts(array('post_type' => $postType,'numberposts' => -1)); //loop through menu items, getting current prices , add 10% to each price and resave meta foreach($menuItems as $menuItem){ //print info print PHP_EOL."
UPDATING ".$menuItem -> post_title." [ID ".$menuItem -> ID."]
".PHP_EOL; //get current menu item meta data $objMetaData = get_post_meta($menuItem -> ID, $postType, true ); //loop through prices foreach($objMetaData['prices'] as $key => $price){ //adding 10 percent.... $objMetaData['prices'][$key] *= (1 + $percent / 100); //round as per plugin settings.... $objMetaData['prices'][$key] = wppizza_round($objMetaData['prices'][$key]); //print info print" - old price: " . $price . " | new price : " . $objMetaData['prices'][$key] . "
".PHP_EOL; } //re-save meta - comment this line out if you want to view the results first update_post_meta($menuItem -> ID, $postType, $objMetaData) ; } //print info print"----- ALL PRICES UPDATED, DELETE/DISABLE THIS SCRIPT NOW !!! -------"; exit(); } return; }

Usage:
To run this script, add it somewhere where it would be read (your functions.php for example) login to the WP backend and go to http[s]://[your-domain]/wp-admin/?runonce=1 .
DO NOT RELOAD THAT PAGE – SEE ABOVE. The one screen message will tell you when it’s done.

If you want to do the same with the prices of any ingredients of the “WPPizza Add Ingredients” plugin you could do the following in a similar fashion

//script must be run on init or later or things will not work 
add_action( 'init', 'myprefix_update_wppizza_ingredients_prices');
function myprefix_update_wppizza_ingredients_prices(){
	/* 
		the percentage to add to all ingredients prices 
		change as required
	*/
	$percent = 10;

	//same conditional as above 
	if( is_admin() && current_user_can('wppizza_cap_menu_items') && isset($_GET['runonce'])){	
		//ingredients options slug 
		$options_slug = 'wppizza_addingredients';
		
		//get current ingredients option
		$ai_options = get_option($options_slug, 0);
		
		//loop through ingredients , add 10% to each price 
		if(!empty($ai_options['ingredients'])){
		foreach($ai_options['ingredients'] as $key => $ingredient){	
			if(!empty($ingredient['prices'])){
			foreach($ingredient['prices'] as $pKey => $price){
				$ai_options['ingredients'][$key]['prices'][$pKey] *= (1 + $percent / 100);
				$ai_options['ingredients'][$key]['prices'][$pKey] = wppizza_round($ai_options['ingredients'][$key]['prices'][$pKey]);	
			}}				
		}}
		
		/*
			re-save options back to db
		*/
		update_option($options_slug, $ai_options );	
	
	//print info
	print"----- ALL INGREDIENTS PRICES UPDATED, DELETE/DISABLE THIS SCRIPT NOW !!! --------";	
	exit();
	}
	
return;
}
]]>
WPPizza Mailinglists https://docs.wp-pizza.com/wppizza-mailinglists/ Tue, 22 Nov 2022 14:23:39 +0000 https://docs.wp-pizza.com/?p=495 Order Settings -> Mailinglists : Customers Name Formfield" b) Create a custom field for your selected ]]> Customisations of selected WPPizza Mailinglists

Freshmail

@param: array
@return: array

/*
Adding preconfigured custom fields
*/
add_filter('wppizza_mll_freshmail_custom_fields', 'myprefix_freshmail_customfields');
function myprefix_freshmail_customfields($custom_fields){ 
	/*
		a) Assign the appropriate field in "WPPizza -> Order Settings -> Mailinglists : Customers Name Formfield"
		b) Create a custom field for your selected mailinglist with a "Field Name" of "name" - type text. (The tag will be $$name$$)
		c) Set  $custom_fields['name'] below to boolean true to enable. 
	*/
	$custom_fields['name'] = false;
	/*
		a) Assign the appropriate field in "WPPizza -> Order Settings -> Mailinglists : Customers Phone Formfield"
		b) Create a custom field for your selected mailinglist with a "Field Name" of "phone" - type text. (The tag will be $$phone$$)
		c) Set  $custom_fields['phone'] below to boolean true to enable.
	*/
	$custom_fields['phone'] = false;
	
	/*
		a) Assign the appropriate field in "WPPizza -> Order Settings -> Mailinglists : Customers Address Formfield"
		b) Create a custom field for your selected mailinglist with a "Field Name" of "address" - type text. (The tag will be $$address$$)
		c) Set $custom_fields['address'] below to boolean true to enable.
	*/
	$custom_fields['address'] = false;

return $custom_fields;
}

Note: As of writing there’s a bug (known to Freshmail) – in the api that does not allow to fill the “name” field that exists by default associated to an email address.
If you need to avoid confusion (perhaps by using something like “Full Name” instead of using ‘name’ in the preconfigured filter above), use the full filter below instead to use a “Full Name” custom field for example (or any other custom filed you would like to add)

@param: array
@return: array

/*
Example, adding a full name custom field.
*/
add_filter('wppizza_mll_freshmail_parameters ', 'myprefix_freshmail_parameters', 10 ,  2);
function myprefix_freshmail_parameters($parameters, $customer_data){ 

	/*
		a) Create a customfield  - type text - for your selected mailinglist with a "Field Name" of "Full Name". (The tag will be $$full_name$$)
		b) Add the a $custom_fields['full_name'] like so . 
	*/
	$parameters['custom_fields']['full_name'] = (!empty($customer_data['name']) ? $customer_data['name'] : '' );//Set full name from customer_data parameters
	

return $parameters;
}

]]>
Coupons and Discounts https://docs.wp-pizza.com/coupons-and-discounts/ Sat, 26 Mar 2022 21:37:35 +0000 https://docs.wp-pizza.com/?p=487 …]]> Filters available for WPPizza Coupons and Discounts

wppizza_cad_filter_discounts

Allow to filter (unset) applied discounts – identified by their ID – depending on custom conditions related to cart contents. As with all customisations, use at your own risk. You should test this thoroughly

/*
@since 2.1.4
@param array
@param array
@return array

EXAMPLE:
Remove a specific applied simple discount - identified by its id - if cart contains an item from a certain category
*/
add_filter('wppizza_cad_filter_discounts', 'myprefix_filter_wppizza_cad_filter_discounts', 10, 2);
function myprefix_filter_wppizza_cad_filter_discounts($array_of_discount_ids, $cart){
	/*
		skip if there isn't anything in the cart to start off with
	*/
	if(empty($cart)){
		return $array_of_discount_ids;
	}

	/*
		discount id to remove if cat id in cart
	*/
	$discountIdToRemove = 1;	
	//skip if it does not exist in array anyway
	if(empty($array_of_discount_ids[$discountId])){
		return $array_of_discount_ids;
	}
		
	/*
		check for category id used by an item in cart
	*/
	$findCatId = 6;
	
	/*
		array keys of items consist of blogid.categoryid.postid.sizes and more
		
		Note:
		there are also many other ways of doing this by iterating through all items or similar....
		whatever works for you
	*/
		
	//get all keys cart 
	$cart_item_keys = array_keys($cart);
	
	//iterate through keys to get category id's
	foreach($cart_item_keys as $cart_item_key){
		
		//explode keys by '.'
		$x = explode('.',$cart_item_key);
		
		/* 
			Example: 
			if one of the items in the cart belongs to cat id = 6 , 
			remove discount with id 1 

			$x[0] => blog id
			$x[1] => cat id
			$x[2] => post id
			$x[3] => sizes id
			$x[4] => size id
			.....
		*/
		if($x[1] == $findCatId){
			unset($array_of_discount_ids[$discountIdToRemove]);
			break;//no need to continue iteration now	
		}
	}
	
return $array_of_discount_ids;
}
]]>
Preorder https://docs.wp-pizza.com/preorder/ Wed, 03 Feb 2021 14:44:10 +0000 https://docs.wp-pizza.com/?p=470 …]]> Customisations WPPizza Preorder

Highlighting preorders for days after today in *emails* sent (for print templates, simply use css declarations)

Your email template(s) selected MUST be set to “Html” for this to make any difference set conditionals as required

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

add_filter( 'wppizza_filter_template_section_customer_styles', 'myprefix_set_email_styles', 10, 5 );
function myprefix_set_email_styles($template_styles, $parameters, $template_type, $template_id, $order){
	/*
	restricting to email templates here 
	*/
	if($template_type == 'emails'){
	
		/*
			set as variable for ease of use 
		*/
		$pluginSlug = 'wppizza_preorder';
	
		/*
			get preorder meta value / timestamp
			this will be something like '2021-02-11 13:45:00' OR 'asap' if nothing was selected
		*/
		$preorder =  wppizza_get_order_meta($order['ordervars']['order_id']['value'], $pluginSlug, true );
		
		/*
			end of day today, based on wordpress timezone settings current time
		*/
		$eod = date('Y-m-d 23:59:59', WPPIZZA_WP_TIME);
		
		/*
			as an example, make the preorder text in the emails red if 
			preorder time is on/after midnight tonight and set fontsize
			set your conditionals as required
		*/
		if($preorder !='asap' && $preorder > $eod ){
			$template_styles[''.$pluginSlug.'-tdall'] = 'color:red;font-size:120%';
		}
		
	}
return $template_styles;
}

Adding additional date format(s) – (see php date format for details)

As with all customisations, use at your own risk. You should test this thoroughly, especially if you want to use textual representations of a part of the date (months, weekdays) or separators other than:

  • “/”(slash)
  • “-“(hyphen)
  • ” “(space)
  • “.”(dots)

Whatever you do, do not use/enable “j F, Y” here as the comma after a textual month will stop the javascript library used from validating the date

@param: array
@return: array

add_filter( 'wppizza_po_filter_dateformat', 'myprefix_add_po_date_format');
function myprefix_add_po_date_format($date_format){
	/* just as example how to do this, this already exists as an option */
	$date_format[] = 'M j, Y';
return $date_format;
}

Alter preorder date/time format *after an order has been made* (I.e in thank you page, emails etc ), regardless of plugin settings

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

add_filter('wppizza_filter_order_details_formatted', 'my_custom_details_formatted', 10, 4);
function my_custom_details_formatted($order_formatted, $order_ini, $customer_ini, $order_values){
	
	/*
		preorder plugin slug
	*/
	$plugin_slug = 'wppizza_preorder';
	
	/*
		order id
	*/
	$order_id = $order_values['id'];
	
	/*
		get preorder metavalue timestamp, and reformat from timestamp
		skip if 'asap' 
	*/
	$preorder_meta_value = wppizza_get_order_meta( $order_id, $plugin_slug, true);	
	
	if(!empty($preorder_meta_value) && $preorder_meta_value != 'asap'){
		
		/* 
			set desired format 
		*/
		$custom_format = date('l, d M Y @ H|i|s', strtotime($preorder_meta_value));
		/* 
			alter output of preorder value in emails prints etc
		*/		
		$order_formatted['sections']['customer'][$plugin_slug]['value'] = $custom_format;
		

	}


return $order_formatted;	
}

]]>
Plugin Options https://docs.wp-pizza.com/plugin-options/ Tue, 10 Nov 2020 16:49:21 +0000 https://docs.wp-pizza.com/?p=452 …]]> Display a set WPPizza plugin option Display the (raw, unformatted) value of an option set in the WPPizza plugin (strings only).
Use your browsers element inspector on an input element to determine the page/parameter combination. If you need access to other parameters not returned by this shortcode (i.e something that would return an array or similar) use the global $wppizza_options; in your php code in whichever way you need to (and then do something like echo $wppizza_options['localization']['common_label_order_order_id']; for example). type=’options’ required string   page=’localization’ required string The admin page (slug) this option can be found on parameter=’common_label_order_order_id’ required string The option key you want to display
Examples
 
[wppizza type='options' page='localization' parameter='common_label_order_order_id']
– Would simply output what you have set in “Wppizza -> Localization -> Common [Order Labels] -> order id”.
(I.e smething like “Order ID:”)
[wppizza type='options' page='order_settings' parameter='order_pickup_preparation_time']
– Display the order preparation time as set in “WPPizza->Order Settings->Pickup->Preparation Time”.
(I.e something like “30”)
]]>
Layout (Menu Items, General) https://docs.wp-pizza.com/layout/ Fri, 03 Jul 2020 12:15:44 +0000 https://docs.wp-pizza.com/?p=433 Layout” Goto “Style” on that page and choose from one of the style options ]]> If you wish to alter the display of the WPPizza menu items – alongside many other layout elements – from the installed default, use any of the options below

  • Goto “WPPizza ->Layout”

    Goto “Style” on that page and choose from one of the style options available (currently “default”, “responsive” and “grid” ) as your main / base menu item layout.

    Adjust all other layout options on that page as required
  • Change the order of how elements are displayed by adjusting the “elements” attribute of the shortcodes on your pages according to the shortcode documentation

    For full shortcode attributes list available refer to that same documentation please.
  • Adjust the css according to the css documentation here

In 99% of cases a combination of the above the should let you adjust the layout as you require to fully integrate with your chosen theme I would think (make sure you test any changes you make on multiple devices ).
However, if you still feel the need to modify the templates themselves please refer to the templates documentation

]]>
Checkout Formfields https://docs.wp-pizza.com/checkout-formfields/ Mon, 25 May 2020 15:40:47 +0000 https://docs.wp-pizza.com/?p=422 …]]> Modify the customer form fields available on the checkout page

A few examples as to how you can show/hide/add/modify input formfields available on the checkout page

Simple show/hide formfields using css selectors

If you wish to simply show hide some formfields when an order is set to be a pickup order.
See here , for options as to where to add this css

example:

/**********************************************************
	target specific elements on pickup
	use your browsers element inspector to ascertain the exact classname you need to target
**********************************************************/
.wppizza-order-ispickup .wppizza-personal-details > .wppizza-cname{display:none}
.wppizza-order-ispickup .wppizza-personal-details > .wppizza-caddress{display:none}
/* etc etc */

Make sure to not hide things that you have also set to be “required” (unless they are already prefilled in some way) or the customer will never be able to check out …

wppizza_register_formfields

Add / modify a formfield on the checkout page. First of all, you can of course already add/remove and conditionally set various formfield properties by going to WPPizza ->Order Form. If you however need some more granular control or simply add your own, see the examples below

.

example:

/*************************************************** 
	add the filter and corresponding function
****************************************************/
add_filter('wppizza_register_formfields', 'my_prefix_modify_wppizza_formfields');
function my_prefix_modify_wppizza_formfields($formfields){

	/* 
		*unique* identifier for the formfield you want to add
		if you add more than one, each one must be a unique id
		for simplicity and demonstration purposes the some is being used here for all !

		if you wish ta alter an already existing formfield use that formfields key instead 
		a print_r($formfields) will show you all registered formfields and their keys if you need to identify a particular one 

	*/
	$unique_ident = 'my_unique_formfield_id';


	/*********************************************** 
		adding a text formfield 
	***********************************************/
	$formfields[$unique_ident ] = array(
	
		/* sort order - at which position is this field displayed */
		'sort' => 100,

		/* the unique ident  */
		'key' => $unique_ident ,

		/* label displayed for the formfield */
		'lbl' => 'some label',

		/* should be defined as an array, with the first value being false  */
		'value' => array(false),

		/* set to text to display a text input */
		'type' => 'text',

		/* 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,

		/* input placeholder  */
		'placeholder' => 'my placeholder',

		/* validation as available wppizza->order form. as there can be multiple validation rules, this should be an array*/
		'validation' => array(
			'default' => true,
		),			
	);


	/*********************************************** 
		adding a select dropdown
	***********************************************/
	$formfields[$unique_ident ] = array(
	
		/* sort order - at which position is this field displayed */
		'sort' => 100,

		/* the unique ident  */
		'key' => $unique_ident ,

		/* label displayed for the formfield */
		'lbl' => 'some label',

		/* an array of available dropdown values*/
		'value' => array('1st value','2nd value','3rd value','Nth value'),

		/* 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,
		),			
	);


	/*********************************************** 
		adding radio inputs 
	***********************************************/
	$formfields[$unique_ident ] = array(
	
		/* sort order - at which position is this field displayed */
		'sort' => 100,

		/* the unique ident  */
		'key' => $unique_ident ,

		/* label displayed for the formfield */
		'lbl' => 'some label',

		/* an array of available radio values*/
		'value' => array('1st value','2nd value','3rd value','Nth value'),

		/* set to select to display radio choices */
		'type' => 'radio',

		/* 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,

		/* ignored for radios  */
		'placeholder' => false,

		/* validation as available wppizza->order form. as there can be multiple validation rules, this should be an array, 
		however as these are radio inputs, the rules as set below are really the only sensible setting here
		*/
		'validation' => array(
			'default' => true,
		),			
	);


	/*********************************************** 
		adding a checkbox
	***********************************************/
	$formfields[$unique_ident ] = array(
	
		/* sort order - at which position is this field displayed */
		'sort' => 100,

		/* the unique ident  */
		'key' => $unique_ident ,

		/* label displayed for the checkbox */
		'lbl' => 'some label',

		/* ignored, but should be set to avoid php notices*/
		'value' => array(false),

		/* set to select to display multiple checkbox choices */
		'type' => 'checkbox',

		/* 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,

		/* ignored for checkboxes*/
		'placeholder' => false,

		/* validation as available wppizza->order form. as there can be multiple validation rules, this should be an array, 
		however as these are radio inputs, the rules as set below are really the only sensible setting here
		*/
		'validation' => array(
			'default' => true,
		),			
	);

	/*********************************************** 
		adding multiple checkbox choices
	***********************************************/
	$formfields[$unique_ident ] = array(
	
		/* sort order - at which position is this field displayed */
		'sort' => 100,

		/* the unique ident  */
		'key' => $unique_ident ,

		/* label  */
		'lbl' => 'some label',

		/* an array of checkboxes */
		'value' => array('1st value','2nd value','3rd value','Nth value'),

		/* set to select to display multiple checkbox choices */
		'type' => 'multicheckbox',

		/* 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,

		/* ignored for checkboxes*/
		'placeholder' => false,

		/* validation as available wppizza->order form. as there can be multiple validation rules, this should be an array, 
		however as these are radio inputs, the rules as set below are really the only sensible setting here
		*/
		'validation' => array(
			'default' => true,
		),			
	);

	/*********************************************** 
		adding a hidden formfield 
	***********************************************/
	$formfields[$unique_ident ] = array(
	
		/* sort order - at which position is this field displayed */
		'sort' => 100,

		/* the unique ident  */
		'key' => $unique_ident ,

		/* ignored for hidden fields */
		'lbl' => false,

		/* should be defined as an array, with the first value being false  */
		'value' => array(false),

		/* set to hidden to display a hidden input */
		'type' => 'hidden',

		/* true to enable (pointless to set this to false)*/
		'enabled' => true,

		/* true to make the field required on delivery, false otherwise . 
		Warning: if you set this to true, without prefilling it (see below) the customer will never be able to order when delivery is selected !
		*/
		'required' => true,

		/* true to make the field required on pickup, false otherwise . 
		Warning: if you set this to true, without prefilling it (see below) the customer will never be able to order when pickup is selected !
		*/
		'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,

		/* ignored for hidden fields  */
		'placeholder' => false ,

		/* validation as available wppizza->order form. as there can be multiple validation rules, this should be an array, 
		however as this is a hidden inputs, the rules as set below are really the only sensible setting here
		*/
		'validation' => array(
			'default' => true,
		),			
	);




	/*********************************************** 
		removing a formfield 
		simply unset , or disable
	***********************************************/
	unset($formfields[$unique_ident]); //unset
	$formfields[$unique_ident]['enabled'] = false ; //disable


	/*********************************************** 
		if you want to disable/not show
		a field when pickup is selected
	***********************************************/
	if(wppizza_is_pickup()){//simply use !wppizza_is_pickup() for the reverse
		unset($formfields[$unique_ident]); //unset
		$formfields[$unique_ident]['enabled'] = false ; //disable
	}



return $formfields;
}

For additional conditionals that might be useful (‘cart is empty’ and similar), also see here

Pre-filling form fields

If a formfield is set to have ‘onregister’ and ‘prefill’ set to true, the relevant value will be prefilled/selected when a user logs in, if you want to or need to (especially with hidden fields) always pre-set a specific value I’d suggest something like the below

example:

add_action('init', 'myprefix_prefill_formfields');
function myprefix_prefill_formfields(){

	/*
	prefill a value if it has not ever been set
	*unique* identifier for the formfield you want to prefill 
	*/
	$unique_ident = 'my_unique_formfield_id';

	if(!isset($_SESSION[WPPIZZA_SLUG.'_userdata'][$unique_ident])){
		
		/* text / hidden formfields */
		$_SESSION[WPPIZZA_SLUG.'_userdata'][$unique_ident] = 'some input value';
		
		/* radios - one of the values as defined in 'value' array of the registered formfield*/
		$_SESSION[WPPIZZA_SLUG.'_userdata'][$unique_ident] = '2nd value';

		/* checkbox (single) - boolean */
		$_SESSION[WPPIZZA_SLUG.'_userdata'][$unique_ident] = true; //bool

		/* checkbox (multiple)  - one or more of the values as defined in 'value' array ofthe  registered formfield*/
		$_SESSION[WPPIZZA_SLUG.'_userdata'][$unique_ident] = array('1st value','3rd value') ; //array
	}
	
return;
}
]]>
Email Subject Line https://docs.wp-pizza.com/email-subject-line/ Wed, 25 Mar 2020 18:37:19 +0000 https://docs.wp-pizza.com/?p=403 …]]> Change the default subject line used in emails

wppizza_filter_email_subject

/*** 
	email subject lines are made up of 3 parts 
	filter each part as required based on your preferences

****/
add_filter('wppizza_filter_email_subject', 'myprefix_filter_email_subject', 10, 2);
function myprefix_filter_email_subject($subject, $order_formatted){

	/*
		defaults

		//dynamic depending on settings in wppizza order form , but typically its the site name plus perhaps some personal info */
		$subject['prefix'] 	= '[--------- conditional/dynamic text ---------------]' ;
	
		//from wppizza->localization
		$subject['main'] 	= $order_formatted['localization']['your_order'];
	
		//date/time according to wordpress date/time settings */	
		$subject['suffix'] 	= date_i18n($order_formatted['date_format']['date'], WPPIZZA_WP_TIME)." ".date_i18n($order_formatted['date_format']['time'], WPPIZZA_WP_TIME)."";

		//This typically produces something like
		"My Shop Your Order March 25, 2020 6:31 pm" 
		where:
		$subject['prefix'] = 'My Shop';
		$subject['main']= 'Your Order';
		$subject['suffix']= 'March 25, 2020 6:31 pm';
	*/

	// example: if you want to not add the date/time at the end
	$subject['suffix'] = '';	
	//or simply
	unset($subject['suffix']);	

	// example: change the typically main "My Order"
	$subject['main'] 	= 'whatever it is you want';

	// example: add something after it all
	$subject['some_additional_key'] 	= 'something added to the end of the subject line;

	/*
		for conditionals depending on order values, 
		you can use the 2nd "$order_formatted" parameter
	*/

return $subject;
}

As of version 3.6.7+ an additional parameter has been added to the filter with the order details already formatted

add_filter('wppizza_filter_email_subject', 'prefix_filter_email_subject', 10 , 3);
function prefix_filter_email_subject($subject, $order, $order_formatted){

	/* 
	$subject is an array made up of 
	$subject['prefix'] - typically contains blogname followed by items added to subject line in wppizza->order form 
	$subject['main'] - typically contains "your order" localization string (wppizza->localization)
	$subject['suffix'] - typically contains date of order according to date/time format set in WP->settings
	*/
	
	/* example: adding the label of a gateway as set in wppizza->gateways after the prefix , tweak as required*/	
	$subject['prefix'] .= ' '.$order_formatted['ordervars']['payment_type']['value_formatted'];
	
	/* example2: adding the paymet method (i.e typically simply  "Cash" or "Credit Card" ) , tweak as required*/	
	$subject['prefix'] .= ' '.$order_formatted['ordervars']['payment_method']['value_formatted'];
	
	/* see $order_formatted for all available parameters */

	return $subject;
}

If you require more granular control over email parameters, you can also use the ‘wppizza_filter_email_settings’ filter (I believe the attributes are self-explanatory)

add_filter('wppizza_filter_email_settings', 'prefix_filter_email_settings', 10 , 3);
function prefix_filter_email_settings($email_settings, $recipient_key, $order_formatted){
	/* do your thing */

return $email_settings;
}

]]>
Enable Debug https://docs.wp-pizza.com/enable-debug/ Tue, 13 Jun 2017 10:01:01 +0000 http://v3x.wp-pizza.com/?p=73 …]]> In your wp-config.php you will find a line that reads (most likely) like this:
define('WP_DEBUG', false);

REPLACE this with (or if it does not exist simply add the below)


define('WP_DEBUG', true);
define('WP_DEBUG_LOG', true);
define('WP_DEBUG_DISPLAY', false);/*this should NEVER be true for production sites*/

Note: this MUST be before /* That's all, stop editing! Happy blogging. */

Which will generate a file “wp-content/debug.log” if and when any errors are encountered.
Check this file for errors if you need to find out where things might go wrong

View the Help Screen

Note that in many cases a lot more information/help is available in the help screens of the plugin

View your browsers console (Typically by using Ctrl+Shift+I)

If you see some “500 Internal server errors” in there, check your server error log. In many cases these are caused by uploading a plugin with the wrong permissions – especially if you add plugins by ftp instead of using the standard wordpress plugin installer. You should also aim to fix any other javascript errors you may have, although some might be more problematic than others

General Troubleshooting

If you have issues with WPPizza – or WordPress in general for that matter – I would highly recommend the following resource(s) to narrow down where your issue(s) might be

As I could not say this any better, forgive me for simply providing the links above. I would, however, especially recommend the “Troubleshooting Plugins” section on the perishablepress.com link ; about 2 thirds down on that page.

Of course, if you have followed the recommendations on those pages without being able to solve your problem and still have issues with WPPizza, please get in touch via the usual channels (forum, contact form, emails)

]]>
Powered by atecplugins.com