PHP Class WC_Abstract_Legacy_Order

Legacy and deprecated functions are here to keep the WC_Abstract_Order clean. This class will be removed in future versions.
Author: WooThemes
Inheritance: extends WC_Data
Show file Open project: woocommerce/woocommerce Class Usage Examples

Public Methods

Method Description
__get ( string $key ) : mixed Magic __get method for backwards compatibility.
__isset ( string $key ) : boolean Magic __isset method for backwards compatibility.
add_coupon ( string $code = [], integer $discount, integer $discount_tax ) : integer Add coupon code to the order.
add_fee ( object $fee ) : integer Add a fee to the order.
add_shipping ( $shipping_rate ) : integer Add a shipping row to the order.
add_tax ( $tax_rate_id, integer $tax_amount, integer $shipping_tax_amount ) : integer Add a tax row to the order.
cancel_order ( string $note = '' ) Cancel the order and restore the cart (before payment).
decrease_coupon_usage_counts ( ) Decrease applied coupon counts.
display_item_downloads ( array $item ) Display download links for an order item.
display_item_meta ( array $item ) Display meta data belonging to an item.
email_order_items_table ( array $args = [] ) : string Output items for display in html emails.
expand_item_meta ( array $item ) : array Expand item meta into the $item array.
get_download_url ( integer $product_id, integer $download_id ) : string Get the Download URL.
get_item_downloads ( array $item ) : array Get the downloadable files for an item in this order.
get_item_meta ( mixed $order_item_id, string $key = '', boolean $single = false ) : array | string Get order item meta.
get_item_meta_array ( mixed $order_item_id ) : array Get all item meta data in array format in the order it was saved. Does not group meta by key like get_item_meta().
get_order ( integer $id ) : boolean Gets an order from the database.
get_order_currency ( ) Get currency.
get_product_from_item ( object $item ) : WC_Product | boolean Get a product (either product or variation).
get_total_shipping ( ) : float Gets shipping total. Alias of WC_Order::get_shipping_total().
has_meta ( string $order_item_id ) : array has_meta function for order items.
increase_coupon_usage_counts ( ) Increase applied coupon counts.
legacy_set_total ( float $amount, string $total_type = 'total' ) : boolean Set an order total.
populate ( mixed $result ) Populates an order from the loaded post data.
record_product_sales ( ) Record sales.
reduce_order_stock ( ) Reduce stock levels for all line items in the order.
send_stock_notifications ( $product, $new_stock, $qty_ordered ) Send the stock notifications.
set_address ( array $address, string $type = 'billing' ) Set the customer address.
update_coupon ( object | integer $item, array $args ) : integer Update coupon for order. Note this does not update order totals.
update_fee ( object | integer $item, array $args ) : integer Update fee for order.
update_product ( object | integer $item, WC_Product $product, array $args ) : integer Update a line item for the order.
update_shipping ( object | integer $item, array $args ) : integer Update shipping method for order.
update_tax ( object | integer $item, array $args ) : integer Update tax line on order.

Protected Methods

Method Description
init ( integer | object | WC_Order $order ) Load the order object. Called from the constructor.

Method Details

__get() public method

Magic __get method for backwards compatibility.
public __get ( string $key ) : mixed
$key string
return mixed

__isset() public method

Magic __isset method for backwards compatibility.
public __isset ( string $key ) : boolean
$key string
return boolean

add_coupon() public method

Add coupon code to the order.
public add_coupon ( string $code = [], integer $discount, integer $discount_tax ) : integer
$code string
$discount integer tax amount.
$discount_tax integer amount.
return integer order item ID

add_fee() public method

Order must be saved prior to adding items.
public add_fee ( object $fee ) : integer
$fee object
return integer updated order item ID

add_shipping() public method

Add a shipping row to the order.
public add_shipping ( $shipping_rate ) : integer
return integer order item ID

add_tax() public method

Add a tax row to the order.
public add_tax ( $tax_rate_id, integer $tax_amount, integer $shipping_tax_amount ) : integer
$tax_amount integer amount of tax.
$shipping_tax_amount integer shipping amount.
return integer order item ID

cancel_order() public method

Cancel the order and restore the cart (before payment).
Deprecation: 2.7.0 Moved to event handler.
public cancel_order ( string $note = '' )
$note string (default: '') Optional note to add.

decrease_coupon_usage_counts() public method

Decrease applied coupon counts.
Deprecation: 2.7.0

display_item_downloads() public method

Display download links for an order item.
public display_item_downloads ( array $item )
$item array

display_item_meta() public method

Display meta data belonging to an item.
public display_item_meta ( array $item )
$item array

email_order_items_table() public method

Output items for display in html emails.
Deprecation: 2.7.0 Moved to template functions.
public email_order_items_table ( array $args = [] ) : string
$args array Items args.
return string

expand_item_meta() public method

Expand item meta into the $item array.
Deprecation: 2.7.0 Item meta no longer expanded due to new order item classes. This function now does nothing to avoid data breakage.
public expand_item_meta ( array $item ) : array
$item array before expansion.
return array

get_download_url() public method

Get the Download URL.
public get_download_url ( integer $product_id, integer $download_id ) : string
$product_id integer
$download_id integer
return string

get_item_downloads() public method

Get the downloadable files for an item in this order.
public get_item_downloads ( array $item ) : array
$item array
return array

get_item_meta() public method

Get order item meta.
Deprecation: 2.7.0
public get_item_meta ( mixed $order_item_id, string $key = '', boolean $single = false ) : array | string
$order_item_id mixed
$key string (default: '')
$single boolean (default: false)
return array | string

get_item_meta_array() public method

Get all item meta data in array format in the order it was saved. Does not group meta by key like get_item_meta().
public get_item_meta_array ( mixed $order_item_id ) : array
$order_item_id mixed
return array of objects

get_order() public method

Gets an order from the database.
Deprecation: 2.7
public get_order ( integer $id ) : boolean
$id integer (default: 0).
return boolean

get_order_currency() public method

Get currency.
Deprecation: 2.7.0
public get_order_currency ( )

get_product_from_item() public method

Get a product (either product or variation).
Deprecation: Add deprecation notices in future release. Replaced with $item->get_product()
public get_product_from_item ( object $item ) : WC_Product | boolean
$item object
return WC_Product | boolean

get_total_shipping() public method

Gets shipping total. Alias of WC_Order::get_shipping_total().
Deprecation: 2.7.0 since this is an alias only.
public get_total_shipping ( ) : float
return float

has_meta() public method

has_meta function for order items.
public has_meta ( string $order_item_id ) : array
$order_item_id string
return array of meta data.

increase_coupon_usage_counts() public method

Increase applied coupon counts.
Deprecation: 2.7.0

init() protected method

Load the order object. Called from the constructor.
Deprecation: 2.7.0 Logic moved to constructor
protected init ( integer | object | WC_Order $order )
$order integer | object | WC_Order Order to init.

legacy_set_total() public method

Set an order total.
public legacy_set_total ( float $amount, string $total_type = 'total' ) : boolean
$amount float
$total_type string
return boolean

populate() public method

Populates an order from the loaded post data.
Deprecation: 2.7
public populate ( mixed $result )
$result mixed

record_product_sales() public method

Record sales.
Deprecation: 2.7.0

reduce_order_stock() public method

Reduce stock levels for all line items in the order.
Deprecation: 2.7.0
public reduce_order_stock ( )

send_stock_notifications() public method

Send the stock notifications.
Deprecation: 2.7.0 No longer needs to be called directly.
public send_stock_notifications ( $product, $new_stock, $qty_ordered )

set_address() public method

Set the customer address.
public set_address ( array $address, string $type = 'billing' )
$address array Address data.
$type string billing or shipping.

update_coupon() public method

Update coupon for order. Note this does not update order totals.
public update_coupon ( object | integer $item, array $args ) : integer
$item object | integer
$args array
return integer updated order item ID

update_fee() public method

Note this does not update order totals.
public update_fee ( object | integer $item, array $args ) : integer
$item object | integer
$args array
return integer updated order item ID

update_product() public method

Note this does not update order totals.
public update_product ( object | integer $item, WC_Product $product, array $args ) : integer
$item object | integer order item ID or item object.
$product WC_Product
$args array data to update.
return integer updated order item ID

update_shipping() public method

Note this does not update the order total.
public update_shipping ( object | integer $item, array $args ) : integer
$item object | integer
$args array
return integer updated order item ID

update_tax() public method

Note this does not update order totals.
Since: 2.7
public update_tax ( object | integer $item, array $args ) : integer
$item object | integer
$args array
return integer updated order item ID