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', 'myprefix_ingredients_filter_email_styles');
function myprefix_ingredients_filter_email_styles($styles){
	/*  
	default styles passed on to $styles parameter are currently as follows (though might get tweaked in the future) 
		
	$styles = array();
	$styles['ingrinfo'] 	= 'white-space: initial; margin: 3px; line-height: 130%;' ;
	$styles['ingr_item'] 	= 'font-style: italic;' ;
	$styles['ingrinfo'] 	= 'white-space: initial; margin: 3px 3px 3px 20px; line-height: 130%; font-size:85%;' ;
	$styles['ingrgrp'] 	= 'white-space: initial; margin: 3px;line-height: 130%;' ;
	$styles['ingrgrp_0'] 	= 'white-space: initial; margin: 3px;line-height: 130%; display:inline' ;
	$styles['ingrgrp_1'] 	= 'white-space: initial; margin: 3px;line-height: 130%; margin-left: 15px' ;
	$styles['ingrgrp_lbl'] 	= 'font-weight: bold; padding-right: 3px;' ;
	$styles['comments'] 	= 'padding: 3px 0; font-size: 75%;' ;
	*/

	/* 

	if you want to - for example - increase the font for each ingredients in your emails to 
	120% instead of the default of 85%, you can do this 

	*/
	$styles['ingrinfo'] .='font-size:120%;';

	/* 
	or you could override the whole declaration , removing any margins etc and setting font to 14px
	*/
	$styles['ingrinfo'] ='font-size:14px;';

return $styles;
}

WordPress inbuilt ‘get_post_metadata’ filter

A snippet you could use to override the ‘half/half’ and/or ‘quarter’ options on a per size basis for any menu item.
I.e if you have a menu item with “small”, “medium”, “large” and “xxl” sizes and have enabled “whole”, “halfs” and “quarters” for this but do *not* want to have the “halfs” or “quarters” option available for the “small” size, you could do something like the below

@param: mixed
@param: int
@param: str
@return: mixed


/*
The below can be condensed somewhat , but for clarity 
we keep conditionals a bit more separate here in this example
*/
//Add the filter, using wordpress inbuilt 'get_post_metadata' filters
add_filter('get_post_metadata', 'myprefix_modify_wppizzaingredients_slices', 100, 3);
function myprefix_modify_wppizzaingredients_slices($metadata, $object_id, $meta_key){

	/*
	making sure we are only ever listening to *frontend* ajax requests here 
	(there are other way to do this too, but for simplicities sake...)
	*/
	if(!empty($_POST['action']) && $_POST['action'] === 'wppizza_ingredients_json' ){

		/* 
		the meta key used in the wppizza add ingredients plugin 
		that determines whether or not half/half and/or quarters was enabled
		*/
		$ai_meta_key = 'add_ingredients_multi';

		//a) check for add_ingredients_multi meta key
		if ( !empty( $meta_key ) && $ai_meta_key == $meta_key ){

			//b) only apply to menu item with id "35" (change as needed)
			/* 
				Option: 
				if you wanted to select a whole category instead - for example category with id 183 - you could use 
				if( isset($_POST['vars']['catId']) && $_POST['vars']['catId'] == 183)	instead
			*/

			if($object_id == 35){	
				// c) only apply to first - typically smallest - size. Sizes are zero indexed , so we look for 0, if you want to target the 2nd size use $_POST['vars']['size'] == 1 and so on)	

				if( isset($_POST['vars']['size']) && $_POST['vars']['size'] == 0){
				
				/*
					set the new meta data to return 
					this will in effect force only the "whole" option to be enabled
					overriding any half/half , quarter settings.
				
					To force half/half instead set a value of:  array( 2 => 2 )
					To force half/half and quarters only (but no whole) set a value of:  array( 2 => 2, 4 => 4 )
					or whatever combination you want to choose
				*/
				$set_meta = array();
				$set_meta[0][$ai_meta_key] = array( 1 => 1);//whole only
				
				
				return $set_meta;
				}
			}
		}
	}

/*
	return standard meta data 
	if conditionals above do not apply
*/
return $metadata;
}