Filters, Actions, Functions – WPPizza Documentation https://docs.wp-pizza.com documentation for the wordpress wppizza plugin (version 3.x) Fri, 26 Aug 2022 15:03:30 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.2 Getting Orders https://docs.wp-pizza.com/function-wppizza_get_orders/ Tue, 15 May 2018 13:19:46 +0000 https://docs.wp-pizza.com/?p=304 …]]> 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 3.5
@ param array
@ return array
Note: compared to the now removed get_orders_completed() all dimensions of the returned array are arrays themselves now. no more mix ‘n’ match between arrays and objects

Overview – more examples can be found at the end of this page

The following values will be used when not setting ANY arguments (which is essentially the default before any dropdown options might be selected in WPPizza -> Order History)

	$args = array(
		'query' => array(
			'wp_user_id' => false , 
			'email' => false , 
			'order_id' => false , 
			'hash' => false , 
			'payment_status' => array('COMPLETED', 'UNCONFIRMED', 'REFUNDED', 'REJECTED') ,
			'order_status' => false , 
			'custom_status' => false ,
			'blogs' => {default depends on options set and if it's a multisite setup. see notes below},
			'summary' => false ,
		),
		'pagination' => array(
			'paged' => 0 ,
			'limit' => {default depends on options set. see notes below},
		),
		'format' => true ,
	)
	//run query, and get results 
	$orders = wppizza_get_orders($args);

	//this would be the same as simply using 
	$orders = wppizza_get_orders();

Available Arguments

$args[‘query’]

query the wppizza orders table according set parameters

  • wp_user_id

    • @param int
    • default false
    • get orders for a specific registered user id or 0 for guest/unregistered users
  • email

    • @param str|array
    • default false
    • get orders that were made using (a) specific email address(es)
    • if querying for one email address only, you can use a simple string value, if more than one use an array of emails
    • Note: email addresses used when ordering may not neccessarily equal to the email address of a registered user, even if a user was logged in
    • If you have set a WPPIZZA_ENCRYPTION_KEY and copied the email addresses hashed (see WPPizza->Settings->Privacy : Help screen) you should query for wppizza_maybe_encrypt_decrypt(’email@domain.com’, true, false, true)
  • order_id

    • @param int
    • default false
    • get an order by it’s specific id in the database
    • Note: in a multisite setup this might return more than one order (see “blogs” below). If querying a single blog only the “pagination” parameter can and will be ignored (as it will only ever return one order)
  • hash

    • @param str
    • default false
    • get an order by the generated hash associated with each order
    • Note: in a multisite setup this might return more than one order (see “blogs” below). If querying a single blog only the “pagination” parameter can and will be ignored (as it will only ever return one order)
  • payment_status

    • @param str|array
    • default array('COD', 'COMPLETED', 'UNCONFIRMED', 'REFUNDED', 'REJECTED')
    • get orders that have a specific payment status
    • permitted values (case insensitive): 'COD', 'COMPLETED', 'UNCONFIRMED', 'CAPTURED', 'REFUNDED', 'REJECTED', 'INPROGRESS', 'INITIALIZED', 'AUTHORIZED', 'CANCELLED', 'PAYMENT_PENDING', 'FAILED'
    • if querying for one status only, you can use a simple string value, if more than one use an array of payment statuses
    • Note: ‘COD’ was only in use in VERY old wppizza installations instead of ‘COMPLETED’ and can be ignored in most cases
    • Unless you are building your own gateway or similar, you typically only have to concern yourself with ‘COMPLETED’, ‘REFUNDED’, ‘REJECTED’, ‘CANCELLED’, ‘FAILED’
  • order_status

    • @param mixed (false|str|array)
    • default false
    • get orders that have a specific order status
    • permitted values (case insensitive) : 'NEW','ACKNOWLEDGED','ON_HOLD','PROCESSED','DELIVERED','REJECTED','REFUNDED','OTHER','CUSTOM_1','CUSTOM_2','CUSTOM_3','CUSTOM_4'
    • if querying for one status only, you can use a simple string value, if more than one use an array of order statuses
    • omit | false to ignore
    • Note: ‘NEW’ is the default for all orders. Whether or not any of the others might have been set depends on “WPPizza->Localization->Admin Order History – Order Statuses”. If in doubt, omit this query value / argument
  • custom_status

    • @param mixed (false|str|array)
    • default not set
    • get orders that have a specific custom status as set in “WPPizza->Localization->Admin Order History – Custom Statuses”
    • permitted values : as per your custom statuses set set, false to ignore, [not-set] (including brackets) to get unset. CaseSenSiTive
    • if querying for one status only, you can use a simple string value, if more than one use an array of custom statuses
    • omit | false to ignore
  • order_date_before

    • @param timestamp (integer)
    • default not set
    • get orders before a certain date / time
    • permitted values : timestamp (integer)
    • date/time queried follows WP timezone set when the order was made (i.e not UTC – unless this is the same as you WP timezone settings of course)
    • omit | false to ignore
  • order_date_after

    • @param timestamp (integer)
    • default none
    • get orders after a certain date / time
    • permitted values : timestamp (integer)
    • date/time queried follows WP timezone set when the order was made (i.e not UTC – unless this is the same as you WP timezone settings of course)
    • omit | false to ignore
  • blogs – (multisite / network setup only, will otherwise be ignored)

    • @param mixed (bool|array)
    • default bool (see notes below)
    • get orders from current , all or selected blogs
    • permitted values : false to query current blog only, true to query all blogs, array of integers to query one or more specific blogs
    • defaults if omitted:
      – returns false (i.e current blog only) if NOT queried on main/parent site or – if on parent site – “WPPizza->Settings->Multisite :Orders/Customers (Admin) – all subsites” is not enabled
      – returns true (i.e all blogs) only if on parent site AND “WPPizza->Settings->Multisite :Orders/Customers (Admin) – all subsites” IS enabled
    • Note: In a single site setup, this parameter will be ignored
  • summary

    • @param bool
    • default false
    • only get a summary for the query such as total number of orders , (sum of) total value of orders. No order data will be returned. Ignores any “pagination” and “format” parameters.

$args[‘meta’] (since v3.8)

query an order for a specific meta key/value

see bottom of this page how to add meta values to an order

  • query

    • @param array of column/value arrays
    • default void
    • restrict order results to orders that have a certain meta_key and/or meta_value set

$args[‘pagination’]

limit results set of the query – ignored if ‘summary’ => true or only querying for a specific ‘order_id’ or ‘hash’ for a single blog only (as it will only ever return one result at most)

  • paged

    • @param int
    • default 0
    • get results from paged offset onwards
  • limit

    • @param int
    • default [int] – as per option set in “WPPizza->Settings->Order History : Max Results”
    • limit results to value set
    • Note: if not set / false / not numeric, pagination will be ignored completely

$args[‘format ‘]

format the output for each order defaults to true. Set to false for unformatted order results – ignored if $args[‘query’][‘summary’] is set

  • blog_options

    • @param bool
    • default false
    • add wppizza options set for each order
    • Note: only useful in a multisite setup and when querying different blogs as they may have different wppizza option settings (such as localization variables for example)
  • class_idents

    • @param bool
    • default false
    • add class idents to each formatted order values, in case you want to output the results somewhere and wish to add consistent class names etc

Examples

Get completed orders for a user with user id 23 (use 0 to query orders from guest/non-registered customers) from the current blog only, limited to first 5 results with output being formatted

Query:

$args = array(
	'query'=>array(
		'wp_user_id' => 23 ,//user id
		'payment_status' => 'COMPLETED',//completed only
		'blogs' => false ,//current blog only
	),
	//order values returned for the first 5 orders found (always by descending date)
	'pagination' =>array(
		'paged' => 0 ,
		'limit' => 5 ,
	),
	//formatting omitted, defaults to true
);
$orders = wppizza_get_orders($args);

 

Results [Array]:

[total_number_of_orders] => 194 // [int] total number of orders found without pagination limit
[total_value_of_orders] => 14265.59 //[float] total value of orders found without pagination limit
[gateways_idents] => Array // [array] of all gateways used in results set 
    (
        [COD] => COD
    )

[number_orders_on_page] => 5 //[int] total number of orders within pagination limit
[value_orders_on_page] => 269.17 //[float] total value of orders within pagination limits

/* 
   array of order values for each order returned withing pagination limits
   the key for each order is always made up of [blog_id]_[order_id]
   but you can also get the blog id in [site][blog_id][value] and the order id in [ordervars][order_id][value]
*/
[orders] => Array
    (
        [1_623] => Array 
            (
                [site] => Array
                    (
                        /*.... site data for this order ....*/
                    )

                [ordervars] => Array
                    (
			/*.... general ordervars data for this order....*/
                    )

                [customer] => Array
                    (
			/*.... customer data for this order....*/
                    )

                [order] => Array
                    (
			/*.... cart items ....*/
                    )

                [summary] => Array
                    (
			/*.... summary of order ()....*/
                    )

            )

        [1_622] => Array
            (
			/* second order results set */
            )

/* more order results */
    )

 

Get completed or confirmed orders with an order status of ‘NEW’ and ‘meta_key’ equals ‘mymetakey’ and ‘meta_value’ equals ‘mymetavalue’. ()

Query:

$args = array(
	'query'=>array(
		'payment_status' => array('CONFIRMED', 'COMPLETED'),//completed only
		'order_status' =>  'NEW',//get orders with status NEW only
	),
	'meta'=>array(
		'query' => array(
			//if you do not want to restrict by meta_key, omit
			array(
				'column' => 'meta_key',
				'value' => 'mymetakey',
			),
			//if you do not want to restrict by meta_value, omit
			array(
				'column' => 'meta_value',
				'value' => 'mymetavalue',
			),
		),
	),
);
$orders = wppizza_get_orders($args);

Results set returned will be as above, restricted to all orders that match the meta query as well

 

Get completed orders of all users (including non-registered/guests) from all blogs, limited to first x results as set in “WPPizza->Settings->Order History : Max Results” with output being formatted and added class idents

Query:

global $wppizza_options;
$args = array(
	'query'=>array(
		'payment_status' => 'COMPLETED',
		'blogs' => true,//will be ignored if not in a multisite setup or simply omit entirely
	),
	'pagination' =>array(
		'paged' => 	0 ,
		'limit' => $wppizza_options['settings']['admin_order_history_max_results'] ,
	),
	'format' => array(
		'class_idents' => true,
	),
);
$orders = wppizza_get_orders($args);

 

Results [Array]:

/* 
as above example, but with class-indent added to each order parameter 
you could use in any outputs for consistent class names (perhaps adding a distinct prefix to each class name as well)
so the order date would now return somthing like this
*/
[orders] => Array
(
    [1_623] => Array
        (
        ............
        [ordervars] => Array
            (
                [order_date] => Array
                    (
                        [label] => Order Date :
                        [value] => 2018-05-15 00:48:08
                        [value_formatted] => May 15, 2018 12:48 am
                        [class_ident] => order-date //this parameter is now added to each one
                    )  
            ............      
            )
         ............ 
		)     
    [1_623] => Array
        (
        	/* second order */
        )
	///etc 
)

 
 

Simply check if there are any new orders, without returning each orders values

Query:

$args = array(
	'query'=>array(
		'payment_status' => 'COMPLETED',//get completed orders only 
		'order_status' => 'NEW',//get orders with status NEW only
		'summary' => true,// only return count/totals
	),
);
$orders = wppizza_get_orders($args);

 

Results [Array]:

[total_number_of_orders] => 194 // [int] total number of orders found without pagination limit
[total_value_of_orders] => 14265.59 //[float] total value of orders found without pagination limit
/* no other parameters will get returned */

Pagination

If you are outputting the order results somehow/somewhere you could use the below helper to add pagination


@ param  [int] : should be the total number of orders returned by order query before limit 
@ param [int] : should equal the limit set in the orders query pagination['limit'] parameter
@ param [int] (default:false if omitted) : if set to an integer (2 for example) will display a max of 2 pagination links either side of current page, and use '...' where appropriate. false to show all links  	
@ param bool (default:true if omitted) : true to display some pagination info underneath button , false to omit
@ param false|int (default:false if omitted): links to current page. set a distinct post id to link to the page with this id (might be required for ajax requests)
@ return str 

$pagination = wppizza_orders_pagination($total_no_of_orders, $limit, $ellipsis, $pagination_info, $post_id);
print $pagination;

Adding/Altering Meta Data – since WPPizza 3.8+

Adding Meta Data to an Order

/* 
 adding 'mymetakey' with a value of 'mymetavalue' to an order, 
 *when an order gets submitted*
 if mymetavalue is not a string/integer it will be serialized 
*/
add_action('wppizza_add_order_meta', 'myprefix_add_order_meta', 10, 2)
/*------------------------------------------------------------------------------
# $param order id 
# $param order values
# $returns int (meta_id added)
------------------------------------------------------------------------------*/
function myprefix_add_order_meta($order_id, $order){
 $meta_id = wppizza_do_order_meta($order_id, 'mymetakey', 'mymetavalue');
return $meta_id;
}
/* 
 adding 'mymetakey' with a value of 'mymetavalue' to an order, 
 *even BEFORE an order gets submitted - i.e as soon as the user arrives on your orderpage *
 if mymetavalue is not a string/integer it will be serialized 

 Note: if you also use 'wppizza_add_order_meta' with the same metakey, 
 'wppizza_add_order_meta' will overwrite the value captured with 'wppizza_add_order_meta_init'
 (as it happens after)
*/
add_action('wppizza_add_order_meta_init', 'myprefix_add_order_meta_init', 10, 1)
/*------------------------------------------------------------------------------
# $param order id
# $returns int (meta_id added)
------------------------------------------------------------------------------*/
function myprefix_add_order_meta_init($order_id){
 $meta_id = wppizza_do_order_meta($order_id, 'mymetakey', 'mymetavalue');
return $meta_id;
}

 

Updating Meta Data for an Order

/* 
 updating metavalues for a specific meta_key relating to a specific order
 if it the meta_key for this order does not exist yet, it will be added, else the value will be updated
 if $meta_value is not a string/integer it will be serialized 
*/
/*------------------------------------------------------------------------------
# $param int - order id we are updating 
# $param str - meta key we are updating
# $param mixed - value to update/insert
# $returns int (meta_id added/updated)
------------------------------------------------------------------------------*/
$order_id = 123;
$meta_key = 'mymetakey';
$meta_value = array( 'key1'=> 'a', 'key2'=> 'b'}
/* or $meta_value = 'new value'; if you want */

$meta_id = wppizza_do_order_meta($order_id, $meta_key, $meta_value);

 

Deleting a specific metakey of Order

/*------------------------------------------------------------------------------
# $param int - order id 
# $param str - meta key we are deleting of this order
# $returns bool
------------------------------------------------------------------------------*/
$order_id = 123;
$meta_key = 'mymetakey';
$meta_id = wppizza_delete_order_meta($order_id, $meta_key');

 

Get metavalue of an Order for a specific metakey

/*------------------------------------------------------------------------------
# $param int - order id 
# $param str - meta key we are querying
# $param bool - return value only
# $returns mixed 
------------------------------------------------------------------------------*/
$order_id = 123;
$meta_name = 'mymetakey';
$meta_value_only = true;
$res =  wppizza_get_order_meta($order_id, $meta_name, $meta_value_only );

Deleting Orders – since WPPizza 3.10+

Deleting an order and its associated meta data by id/blogid

/*------------------------------------------------------------------------------
# $param int - order id 
# $param int - blog id (only relevant in mutisite setups). set blog id to distinctly target order of a specific blog, or false/omit for current blog
# return void
------------------------------------------------------------------------------*/
/* multisite setups: */
$order_id = 123;
$blog_id = 1; 
wppizza_delete_order($order_id, $blog_id);


/* single site setup, simply do: */
$order_id = 123;
wppizza_delete_order($order_id);

 
 
 
 

This is it for the time being, but if you have a particular query you need like help with and you cannot figure out , let me know and I’ll see what I can do

]]>
Filters, Actions, Functions https://docs.wp-pizza.com/filters-actions-functions/ Fri, 16 Jun 2017 00:13:31 +0000 http://v3x.wp-pizza.com/?p=219 …]]> Preamble:

If you want to do any kind of wordpress development other than “point and click” or basics like css etc it is imperative to know how wordpress actions and filters work.
Actions/Filters let extend or change functionality of plugins/themes (or wordpress itself for that matter) without having to touch core files and therefore loosing the ability to ever update anything again or having to re-apply your changes every time a plugin or theme gets updated. (In fact editing core files is just generally a bad idea in any case)

If you do not know about wordpress actions and filters, I would recommend you use your favourite search engine and look for some tutorials (there are plenty of them available) to familiarise yourself with that concept. I promise you, once you understand how these work, a whole new world of wordpress development will open up for you.

A very very basic summary:

  • actions “do” things, filters “change” things (though the 2 are somewhat related)
  • actions/filters (generally speaking) belong in your theme’s – or better still child theme’s – functions.php

that’s it on that front for the time being….

General:

This section aims to document the most important wppizza functions, actions and filters and will expand over time depending on user requests and general usefulness.

If you are missing anything in particular – or indeed have been customising WPPizza v2x and now wish to transfer your cutomisations to wppizza v3.x but cannot find an answer in the documentation here – contact me using the usual channels.

I will – hopefully – be able to point you in the right direction.

However, please note that some filters and actions have changed completely or have even been removed in favour of other ways to do things (like additional shortcode attributes). Furthermore, a few things have been removed entirely in wppizza v3x (mostly for consistency reasons) in favour of alternatives.

Anyway, get in touch and we’ll see what we can do.

Portability – A Suggestion:

Typically – according to the wordpress codex – you would put you alterations into your themes or child themes functions.php as outlined above. However, if you do that you will always have to re-apply said alterations if you decide to switch themes for one reason or another.

Unless your changes are very specific to a particular theme, a far better alternative (as far as I am concerned anyway) would be to create a dedicated WPPizza Custom plugin (or whatever you want to call it) and add all your filterings, actions etc there instead.

The advantage of it being that it is irrelevant what theme you might have enabled and – even more so if you are in a multisite setup with different themes for each subsite – you can simply enable this plugin without having to worry about having to apply your coding to each theme (or subsite if using different themes in a multisite setup – simply network enable the plugin).

To do so, create a file (let’s name it wppizza-customisation.php for example) and add the following to the top of the file:

<?php
/*
Plugin Name: WPPizza Custom Functions
Description: WPPizza custom functions that run regardless of theme used (use instead of putting them into a theme's functions.php)
Version: 0.1
Author: ollybach
Author URI: https://www.wp-pizza.com
*/

/*
add your filters/actions etc here
*/


Add your filters, actions and whatever else you need to do to that file, save and copy this file to your [Wordpress-Install-Path]/wp-content/plugins/ directory (or if you wish into a subdirectory called wppizza-custom or whatever else you want to call it).

Then simply go to your plugins page in your wordpress installation and activate.

Your WPPizza customisations will now be completely independent of any themes or child themes that may or may not be in use.
Furthermore, if you need to do the same things on another WPPizza site you could simply copy this file there and activate the plugin.

Maybe the above is of some use to someone.

]]>
Changing post type arguments https://docs.wp-pizza.com/changing-post-type-arguments/ Tue, 20 Jun 2017 13:21:07 +0000 http://docs.wp-pizza.com/?p=234 …]]> Altering WPPizza custom post type and taxonomy labels and arguments

there are several filters you can use to change the WPPizza custom post type as well as taxonomies labels, arguments. Please refer to WordPress codex regarding register_posttype and register_taxonomy.

wppizza_filter_cpt_lbls

filter wppizza custom post type lables

@param: array (labels of custom post type)
@return: array

example:

add_filter('wppizza_filter_cpt_lbls', 'my_custom_cpt_lables');
function my_custom_cpt_lables($labels){
	/* set your labels as you see fit */
return $labels;
}

wppizza_filter_cpt_args

filter wppizza custom post type arguments

@param: array (arguments of custom post type)
@return: array

example:

add_filter('wppizza_filter_cpt_args', 'my_custom_cpt_args');
function my_custom_cpt_args($args){
	/* set your arguments as you see fit */
return $args;
}

wppizza_filter_ctx_lbls

filter wppizza taxonomy labels

@param: array (labels of taxonomies)
@return: array

example:

add_filter('wppizza_filter_ctx_lbls', 'my_custom_tax_lables');
function my_custom_tax_lables($labels){
	/* set your labels as you see fit */
return $labels;
}

wppizza_filter_ctx_args

filter wppizza taxonomy arguments

@param: array (arguments of wppizza taxonomies)
@return: array

example:

add_filter('wppizza_filter_ctx_args', 'my_custom_tax_args');
function my_custom_tax_args($args){
	/* set your argumentsas you see fit */
return $args;
}
]]>
Global WPPizza functions https://docs.wp-pizza.com/global-wppizza-functions/ Fri, 16 Jun 2017 00:10:09 +0000 http://v3x.wp-pizza.com/?p=218 …]]> Below you will find a number of globally available WPPizza related functions you could use in your own plugin development or for use in filters / actions

wppizza_is_checkout (alias of wppizza_is_orderpage)

determine if the current page the user is on is the WPPizza checkout page as set in WPPizza -> Order Settings -> Global

@return: bool – true if current page is checkout page, false if not.

example:

if(wppizza_is_checkout()){
	/* do something if on checkout page*/
}
/* using alias */
if(wppizza_is_orderpage()){
	/* do something if on checkout page*/
}

wppizza_is_orderhistory

determine if the current page the user is on is the page that contains the shortcode [wppizza type='orderhistory'] to display the users order history

@return: bool – true or false

example:

if(wppizza_is_orderhistory()){
	/* do something if on users order history page*/
}

wppizza_get_categories

get all wppizza categories as set in WPPizza -> Categories

@return: array

example:

$wppizza_categories= wppizza_get_categories();
print_r($wppizza_categories); /* print array of categories */

wppizza_get_menu_items

get all wppizza menu items as set in WPPizza -> Menu Items

@return: array of objects

example:

$wppizza_menu_items = wppizza_get_menu_items();
print_r($wppizza_menu_items ); /* print array of wppizza menu items*/

wppizza_all_additives

get all wppizza additives as set in WPPizza -> Additives

@return: array

example:

$wppizza_all_additives= wppizza_all_additives();
print_r($wppizza_all_additives); /* print array of wppizza additives*/

wppizza_is_pickup

determine if the current user has self pickup selected provided it generally enabled in WPPizza -> Order Settings -> Pickup

@return: bool – true if pickup, false if not.

example:

if(wppizza_is_pickup()){
	/* do something if pickup selected*/
}

wppizza_cart_is_empty

determine if the current user has nothing put into the cart yet

@return: bool – true if there’s nothing in the cart, false if not.

example:

if(wppizza_cart_is_empty()){
	/* do something if nothing in cart*/
}

wppizza_cart_has_items

determine if the current user has something put into the cart (opposite of wppizza_cart_is_empty)

@return: bool – true if there’s something in the cart, false if not.

example:

if(wppizza_cart_has_items()){
	/* do something if something's in the cart*/
}

wppizza_get_cart

get the contents of the cart in a multidimensional array (since version 3.2.7)

@return: array

example:

$wppizza_get_cart = wppizza_get_cart();
print_r($wppizza_get_cart); /* print full array of cart contents*/

wppizza_cart_summary

get a summary of the cart parameters (totals, taxes etc) (since version 3.2.7)

@return: array

example:

$wppizza_cart_summary = wppizza_cart_summary();
print_r($wppizza_cart_summary); /* print array */

wppizza_is_shop_open

determine if the shop is open depending on settings in WPPizza -> Opening Times

@return: bool – true if shop is open, false if not.

example:

if(wppizza_is_shop_open()){
	/* do something if shop's open */
}

wppizza_is_current_businessday

determine if current time is within the current business day (as opening hours can cross midnight) between opening and closing time depending on settings in WPPizza -> Opening Times – requires php 5.3+

@return: bool – true if it is, false if it is not.

example:

if(wppizza_is_current_businessday()){
	/* do something if current time is within the current business day opening hours */
}

wppizza_get_wordpress_pages

get all wordpress pages for current blog

@return: array of objects

example:

$wppizza_get_wordpress_pages= wppizza_get_wordpress_pages();
print_r($wppizza_get_wordpress_pages); /* print array of pages*/

wppizza_get_networkpages

get network sites/pages (current blog only if not in network setup)

@return: array

example:

$wppizza_get_networkpages = wppizza_get_networkpages();
print_r($wppizza_get_networkpages); /* print array of pages*/

wppizza_sizes_available

get all wppizza sizes as set in WPPizza -> Meal Sizes

@return: array

example:

$wppizza_sizes_available= wppizza_sizes_available();
print_r($wppizza_sizes_available); /* print array of wppizza meal sizes*/

wppizza_page_links

get url of WPPizza checkout page as set in WPPizza -> Order Settings -> Global and/or WPPizza amend orderpage as set in WPPizza -> Order Form Settings -> Confirmationpage (if used)

@param: str|false (default false or string of ‘orderpage’ or ‘amendorderlink’)
@return: mixed array|str

examples:

$wppizza_orderpages_urls = wppizza_page_links();
print_r($wppizza_orderpages_urls ); /* returns array of both urls /


$wppizza_orderpage_url = wppizza_page_links('orderpage');
echo  $wppizza_orderpage_url /*; prints url to order page set /


$wppizza_amendorderlink_url = wppizza_page_links('amendorderlink');
echo  $wppizza_amendorderlink_url; /* prints url to amend order page set /

wppizza_format_price

format price according to options set in WPPizza -> Layout ->Prices / Currency Symbols including spacing and currency and decimal formatting

@param: float (should be at least a numeric string . no commas or thousands separators !)
@return: str

example:

$formatted_price = wppizza_format_price(6.5);
echo $formatted_price ; /* prints something like   $ 6.50 */

wppizza_output_format_price

format price according to options set in WPPizza -> Layout ->Prices / Currency Symbols WITH decimal formatting but WITHOUT any spacing or currency symbols

@param: float (should be at least a numeric string . no commas or thousands separators !)
@return: str

example:

$formatted_price = wppizza_output_format_price(3.2);
echo $formatted_price ; /* prints something like 3.20 */

wppizza_breadcrumbs

If your theme does not provide for breadcrumbs, but you want to use them, you can do something like the following. Edit as required

@param: array
@param: array //optional
@param: array //optional
@param: array //optional
@param: int //optional
@param: int //optional

@return: array

example:

//only the first parameter is really needed for the breadcrumbs here, but for completeness all 6 are listed below
add_filter('wppizza_loop_before_menu_items', 'prefix_add_wppizza_breadcrumbs', 10, 6);
function prefix_add_wppizza_breadcrumbs($markup, $txt, $additives, $category, $max_num_pages, $post_count){ 
	// default arguments are as follows
	$args = array();
 	$args['here_text']        = __( 'You are currently here!' );
	$args['home_link']        = home_url('/');
	$args['home_text']        = __( 'Home' );
	$args['link_before']      = '';
	$args['link_after']       = '';
	$args['link_attr']        = ' rel="v:url" property="v:title"';
	$args['delimiter']        = ' » ';              // Delimiter between crumbs
	$args['before']           = ''; // Tag before the current crumb
	$args['after']            = '';// Tag after the current crumb    

	// output the breadcrumbs according to arguments
	$markup['breadcrumbs'] = wppizza_breadcrumbs($args);	

return $markup;	
}

Additional filterhooks available you could use alternatively to the ‘wppizza_loop_before_menu_items’ above or even additionally if you like

 - wppizza_loop_before_header
 - wppizza_loop_after_header
 - wppizza_loop_before_menu_items
 - wppizza_loop_after_menu_items
 - wppizza_loop_before_additives
 - wppizza_loop_after_additives
 - wppizza_loop_before_pagination
 - wppizza_loop_after_pagination
]]>
WPPizza options https://docs.wp-pizza.com/filter-wppizza_filter_options/ Sat, 17 Jun 2017 15:56:49 +0000 http://docs.wp-pizza.com/?p=221 …]]> Filtering wppizza options (for you own plugin development for example)

wppizza_filter_options

if you want change any WPPizza option values depending on some arbitrary setting and or write a plugin that dynamically changes values or any other things that you can think of that needs a WPPizza option to be dynamically change in the frontend the following filter will probably be your main starting point

@param: array ($wppizza_options)
@return: array (return all/filtered options set for the WPPizza plugin)

example:

add_filter('wppizza_filter_options', 'my_prefix_my_options');
function my_prefix_my_options($wppizza_options){
	/* 
	 do something that requires changing an option
	 perhaps utilising some of the global functions that can be found here
	 //docs.wp-pizza.com/developers/?section=global-wppizza-functions
	 use print_r($wppizza_options) to get/see all wppizza options array
	 the keys/values should be quite self-explanatory I would think
	 
	 so, as an example (though somewhat useless and just to demonstrate), closing the shop on pickup 
	*/
	
	 if(wppizza_is_pickup()){
		$wppizza_options['openingtimes']['close_shop_now'] = true;
	}

/* IMPORTANT: you MUST NOT EVER forget to return $wppizza_options here */
return $wppizza_options;
}
]]>
After every order https://docs.wp-pizza.com/action-wppizza_on_order_execute/ Sat, 17 Jun 2017 16:18:36 +0000 http://docs.wp-pizza.com/?p=222 …]]> Run an action after every successful completed order

wppizza_on_order_execute

if you want run an action (i.e your own function/plugin) after an order has been successfully completed, you can hook into wppizza_on_order_execute

@param: int
@param: array (formatted array of order details)
@param: array (an array of print templates output as set in WPPizza ->Templates print can be added to be available as 3rd parameter in the action hook – see below)
@return: void

example:

add_action('wppizza_on_order_execute', 'my_prefix_my_action', 10, 3);
function my_prefix_my_action($order_id, $order_details, $print_templates){
	/* 
		do something that happens after 
		each order has bee completed
	*/
}

wppizza_on_order_execute_get_print_templates_by_id

if also want to have the output of a print template available in the function of the above action add the relevant id’s like so

add_filter('wppizza_on_order_execute_get_print_templates_by_id', 'my_prefix_my_filter');
function my_prefix_my_filter($template_ids){
	/* 
	 add details of a template id defined in WPPizza -> Templates -> Print
	 for it to be available in subsequent wppizza_on_order_execute action hook as 3rd parameter
	*/

	$template_ids[] = 3;/* get details of print template with id 3 */

return $template_ids;
}
]]>
Currency https://docs.wp-pizza.com/currency/ Wed, 20 Sep 2017 23:43:20 +0000 http://docs.wp-pizza.com/?p=258 …]]> change the currency symbol or add a new currency

wppizza_filter_currencies

if you want change currency symbols for a given currency or indeed need to add a new one in case your currency is missing from the 140+ already available

@param: array (array of all currencies with they array key being 3-letter ISO and the value being symbol you want to have displayed)

@return: array

example:

add_filter('wppizza_filter_currencies', 'myprefix_filter_currencies');
function myprefix_filter_currencies($curr){
 
   /* example, changing the default symbol from € to EUR */
    $curr['EUR'] = 'EUR';

    /* 
     example, adding a new currency 
     ABC being the 3-letter ISO and # being the currency symbol to be displayed
    */
    $curr['ABC'] = '#';
   
return $curr;
}
]]>
Powered by atecplugins.com