Delivery By Post/Zipcode

Examples that will NOT require the “Delivery By Post/Zipcode” plugin

There are certain – relatively simple – situations where the “Delivery By Post/Zipcode” plugin would be unnecessary or indeed complete overkill if you want to achieve some of the below outcomes

Ask customer to select a delivery area/postcode

If you do NOT have DIFFERENT delivery prices for different postcodes or delivery areas but ONLY want to check that your customer has at least selected from a list of selectable delivery area/postcodes

  • goto: wppizza->orderform
  • rename/relabel one of the custom fields
  • check enabled
  • check required
  • choose type->select
  • enter a comma separated list of your delivery areas or postcodes.
  • save

Same site, multiple branches

If you want to use the same site for multiple branches and/but want to send the order email to the associated branches email address depending on the branch selected by the customer

  • goto: wppizza->orderform
  • rename/relabel one of the custom fields (let’s say ccustom6 – hover your mouse over the “enable” button to get the relevant id)
  • check enabled
  • check required
  • choose type->select
  • enter a comma separated list of your branches (let’s say “Branch 1, Branch 2, Branch 3” – without the quotes).
  • save

Then add the following filter to your [child] themes functions.php (see here if you don’t know about wordpress filters/actions).

add_filter( 'wppizza_filter_email_settings', 'myprefix_filter_email_settings', 10, 3 );
function myprefix_filter_email_settings($email_settings, $recipient, $order) {
	
	// only filter emails to the shop
	if($recipient === 'shop'){
		//set shop email depending on branch selected 
		if($order['sections']['customer']['ccustom6']['value'] === 'Branch 1'){//Branch 1
			$email_settings['AddAddress'][0]['email'] = '[email protected]';
		}
		elseif($order['sections']['customer']['ccustom6']['value'] === 'Branch 2'){//Branch 2
			$email_settings['AddAddress'][0]['email'] = '[email protected]';
		}
		/* and so forth */
		else{
			/*
				all others - set as required here along the lines above, i.e 
				$email_settings['AddAddress'][0]['email'] = '[email protected]';
				or simply don't set anything / ignore 
				to send to the default email address set for the shop in your order settings
			*/
		}
	}

return $email_settings ;
}

PS: If you do NOT need different shop email addresses to send the order to but only want to allow the customer to select from the available branches, you can simply omit the filter above entirely