Author: super_admin_v3x

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 

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 

The “register” feature doesn’t appear on my site

For registration and registered users features to be available – such as a users order history page – registrations has to be enabled on your site(s).

To do so go to: WP(WordPress) -> Settings -> General and enable Anyone can register

If you are using a multisite setup you will have to do this in the network settings:
WP(WordPress) Network settings -> Registration Settings -> Allow new registrations : User accounts may be registered

Furthermore, please ensure the dedicated "email" field in Wppizza -> Order Form Settings is enabled and set to be required (to allow the user to receive his/her password for a newly created account)
This is the field that has the hardcoded, non-changeable “Type / Validation” of “email”

Note: the “continue as guest / register” options will only show up if the user is NOT logged in already (for obvious reasons), else a simple checkbox that allows to “update my details” will be displayed.

Pickup Opening Times

Change opening times when pickup is selected example to have different openingtimes if a user chooses pickup (pickup must of course be enabled to start off with) A) set the opening times when the customer has selected pickup (requires WPPizza v3.18.10+) Note: The example using 

Cannot add more than one item to cart

This is usually caused by your php sessions not being set-up correctly. In 99.99% of cases this is due to the session save path (php.ini) not being set correctly or at all and/or the directory not existing or not being writable. Typically this would read 

Missing “Place Order” button

Make sure you have enabled at least one gateway in WPPizza->Gateways and “Completely disable online orders” is not checked in WPPizza->Layout

Getting Orders

Querying for WPPizza Orders (WPPizza v3.5+ only) wppizza_get_orders($args) if you want to develop you own script/plugin etc based on any wppizza orders, please refer to the documentation below Note: Result sets will always be sorted by order date in descending order     @ since 

Codesnippets

Codesnippets, using hooks and filters for the wppizza plugin to use in your own development as required

Unconfirmed Orders

Mark orders as unconfirmed initially until some script/user interaction accepts the order.

Requires wppizza 3.3 (but might also work with slightly earlier versions) Note: the basics of this are tested, but further modifications will be required. Read the notes for each filter/action below. This might not work with pre-paid – i.e paid by credit card – orders (not tested). If it does not but you need this you will have to figure out a way to do this yourself as it’s really bad form to tell people you might not accept an order when it was already paid for (in my book anyway).

wppizza_before_order_execute

set an order to be unconfirmed first

example:

/*****************************************************
* set an order to be unconfirmed
******************************************************/
add_action('wppizza_before_order_execute', 'myprefix_execute_as_unconfirmed');
/******************************************************
 * intercepting "normal" execution of cod style orders
 * to set an order to "UNCONFIRMED"
******************************************************/
function myprefix_execute_as_unconfirmed($order){

	/************************************************************
		a made up $transaction_id as there is none yet
		but can be overridden when finally executing/confirming
	************************************************************/
	$order_initiator = $order['ordervars']['payment_gateway']['value'];
	$order_id = $order['ordervars']['order_id']['value'];
	$transaction_id 	=  $order_initiator . WPPIZZA_WP_TIME .  $order_id ;

	/************************************************************
		$custom_update_columns - none 
	************************************************************/
	$custom_update_columns = false;
	
	/************************************************************
		$transaction_details  - set some details if you want or need to
		refer to later or simply false
	************************************************************/
	//$transaction_details['my_prefix']['key'] = 'somekey';
	$transaction_details = false;
	/************************************************************
		$transaction_errors - set to false (as there cannot be any yet)
	************************************************************/
	$transaction_errors = false;
	/************************************************************
		perhaps us __CLASS__ if script used in class - 
		used as an identifier for logging purposes, or an arbitrary string if used outside class
		(no spaces or special chars other than "-" or "_" please though)
	************************************************************/
	$class_name = 'some_identifier';
	/************************************************************
		$check_user_id - should we check for user id too
		to make sure wp_user_id of order we are dealing with matches
		the current users wp_user_id ?
		in same cases this can be set, but if we are receiving 
		notifications from a third party , this should be null
		- in fact, one should quite safely be able to keep it at null
	************************************************************/
	$check_user_id = null;

	/************************************************************
		$unconfirmed - set to true here (that's the point of the plugin after all)
	************************************************************/
	$unconfirmed = true;

	/*
		if you want to send some other, customised emails instead, uncomment and create the function  
		(here myprefix_send_confirmation_message) that sends your custom emails somehow
	*/
	//add_filter('wppizza_on_order_execute_send_email', array($this, 'myprefix_send_confirmation_message'), 10, 5);
	
	
	/************************************************************
		$send_emails - do not send the standard confirmation emails
	************************************************************/
	$send_emails = false;
			
	/*
		execute (capture, omit sending standard emails, and set to UNCONFIRMED instead of complete)
	*/
	$result = wppizza_order_execute($order, $transaction_id, $transaction_details, $transaction_errors, $class_name, $check_user_id, $custom_update_columns, $unconfirmed, $send_emails);
	/* return errors if any, else redirect */
	if(isset($result['error'])){
		print"".json_encode($result)."";
		exit();
	}

	/*
		$result will now be a redirection link and redirect to thank you page with
		UNCONFIRMED details (set in localization)
	*/
	print"".json_encode($result)."";
exit();//we must exit here						
}

wppizza_filter_pages_unconfirmed_markup

add a page reloader on unconfirmed results page

example:

add_filter('wppizza_filter_pages_unconfirmed_markup', 'myprefix_thankyou_page_unconfirmed_reload', 10, 2);
function myprefix_thankyou_page_unconfirmed_reload($markup, $order_formatted){
	if($order_formatted['ordervars']['payment_status']['value'] == 'UNCONFIRMED'){
		$markup['myprefix_refresh_page']='<script>setInterval(function(){window.location = window.location.href;return;},5000);</script>';//reload page every 5 seconds
	}
return $markup;
}

init

accept an order programatically

example:

add_action('init', 'myprefix_accept_order');
/*******************************************************
*
*	accept an order
*	typically done by some script in the backend sending 
*	some post or get vars
*	YOU SHOULD ADD SOME MORE VERIFICATION HERE
*	THE BELOW IS JUST A SKELETON
******************************************************/
function myprefix_accept_order(){
	/*
		a simple check that something was received
		AGAIN, YOU REALLY SHOULD ADD MORE VERIFICATION HERE		
	*/
	if(empty($_REQUEST)){return;}


	/* parameters received, sanitised */
	$parameters = wppizza_sanitize_post_vars($_REQUEST);
	/* we assume $parameters['id'] is the order id */
	$order_id = $parameters['id'];
	

	/*
		check that received id matches an unconfirmed order
		by trying to get an unconfirmed order by order id and UNCONFIRMED status
	*/
	$columns = array();
	$columns['id'] = array('data' => $order_id, 'operator' => '=');
	$columns['payment_status'] = array('data' => 'UNCONFIRMED', 'operator' => '=');
	$order = wppizza_get_order_by_columns($columns);
	
	/* 
		bail if order not found 
	*/
	if(empty($order)){return;}


	/*******
		assuming all is good -
		now execute the previously unconfirmed but now confirmed order
		sending emails , setting to completed etc etc
	********/
	$transaction_id = $order['sections']['ordervars']['transaction_id']['value'] ;//use tx id we have set previously 
	$transaction_details = $parameters;// capture tx detals
	$transaction_errors = false;// there are no errors that can have happened (or script should have bailed earlier already)
	$class_name = 'some_identifier';// for logging, use __CLASS__ if used in calss, else some arbitrary string
	$check_user_id = false;// do not try and match user id as this script is called from somewhere else , not related to the user at this time)
	$custom_update_columns = false;// no additional column update required (unless you want to, check wppizza_order_execute_ipn as to how )
	$unconfirmed = false;// false as we want to complete an order that's already set to unconfirmed
	/*
		now send normal emails etc etc 
	*/
	$complete_order = wppizza_order_execute_ipn($order, $transaction_id, $transaction_details, $transaction_errors, $class_name, $custom_update_columns, $unconfirmed );
	
	return;

}

Add file attachment to email

Adding an arbitrary file attachment to an email – REQUIRES WPPizza v3.2.10 wppizza_filter_mail_attachments alter the filepath and file contents as well as the recipient key according to your requirements. @param: array (current attachments) @param: str (recipient) @param: array (email settings) @param: array (formatted order details)