Developers

  1. Modify Css / Styles / Layout
    1. Frontend Css
    2. Admin Css
  2. Templates
    1. Pages
      1. page.order.php
      2. page.confirm-order.php
      3. page.processing.php
      4. page.thankyou.php
      5. page.cancelled.php
      6. page.purchase-history.php
    2. Order
      1. itemised.php
      2. summary.php
      3. transaction_details.php
    3. Global
      1. orderinfo.php (Widget)
      2. openingtimes.php (Widget)
      3. additives.php (Widget)
      4. navigation.list.php (Widget)
      5. navigation.dropdown.php (Widget)
      6. search.php (Widget)
      7. totals.php (Widget)
      8. pickup_choice.php (Mixed)
      9. login.php (Module)
      10. profile.register.php (Module)
      11. profile.update.php (Module)
      12. pages.pickup_note.php (Module)
      13. formfields.inputs.php (Module)
      14. formfields.values.php (Module)
    4. Cart
      1. cart.container.php
      2. cart.shopclosed.php
      3. cart.empty.php
      4. cart.pickup_note.php
      5. cart.checkout_button.php
      6. cart.empty_cart_button.php
      7. cart.minimum_order.php
      8. minicart.php
    5. Loop (Menu Items)
      1. header.php
      2. no_results.php
      3. posts.title.php
      4. posts.thumbnail.php
      5. posts.prices.php
      6. posts.content.php
      7. posts.permalink.php
      8. additives.php
      9. pagination.php
      10. theme-wrapper.php
    6. Search Results
      1. search.php
    7. Single Menu Item
      1. single.php
    8. functions.php
  3. Filters, Actions, Functions
    1. Global WPPizza functions
    2. WPPizza options (Filter)
    3. Currency (Filter)
    4. After every order (Action)
    5. Getting Orders (Function)
  4. Constants
    1. Admin Name
    2. Admin Menu Icon
    3. SORT_ITEMS_AS_ADDED
    4. SINGLE_PERMALINK_VAR
    5. WIDGET_CSS_CLASS
    6. PLAINTEXT_LINE_LENGTH
    7. ADMIN_{CONSTANTS}
    8. DEV_{CONSTANTS}
    9. INSTALL_{CONSTANTS}
    10. TRANSACTION_{CONSTANTS}
  5. Codesnippets
    1. Create your own sales report
    2. Order history - todays orders
    3. Add attachment to email
    4. On order status update
    5. Unconfirmed Orders
    6. Customise order id
    7. Changing post type arguments
    8. Gateway filter frontend
    9. Users previous orders
    10. Dynamic menu item prices
    11. Prices output loop
    12. Pickup Opening Times
    13. Additional validation function

5.5.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;

}
Yes No Suggest edit
Suggest Edit

documentor id 5