PHP 클래스 WC_Abstract_Order

The WooCommerce order class handles order data.
저자: WooThemes
파일 보기 프로젝트 열기: woocommerce/woocommerce 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$cache_group string A group must be set to to enable caching.
$data array Notes: cart_tax = cart_tax is the new name for the legacy 'order_tax' which is the tax for items only, not shipping.
$data_store_name string Which data store to load.
$items array Order items will be stored here, sometimes before they persist in the DB.
$items_to_delete array Order items that need deleting are stored here.

공개 메소드들

메소드 설명
__construct ( integer | object | WC_Order $order ) Get the order if ID is passed, otherwise the order is new and empty.
add_item ( $item ) Adds an order item to this order. The order item will not persist until save.
add_payment_token ( WC_Payment_Token $token ) : boolean | integer Add a payment token to an order
add_product ( WC_Product $product, integer $qty = 1, array $args = [] ) : integer Add a product line item to the order. This is the only line item type with it's own method because it saves looking up order amounts (costs are added up for you).
calculate_shipping ( ) : float Calculate shipping total.
calculate_taxes ( $args = [] ) Calculate taxes for all line items and shipping, and store the totals and tax rows.
calculate_totals ( boolean $and_taxes = true ) : float Calculate totals by looking at the contents of the order. Stores the totals and returns the orders final total.
get_cart_tax ( string $context = 'view' ) : float Gets cart tax amount.
get_currency ( string $context = 'view' ) : string Gets order currency.
get_data ( ) : array Get all class data in array format.
get_date_created ( string $context = 'view' ) : integer Get date_created.
get_date_modified ( string $context = 'view' ) : integer Get date_modified.
get_discount_tax ( string $context = 'view' ) : string Get discount_tax.
get_discount_to_display ( $tax_display = '' ) : string Get the discount amount (formatted).
get_discount_total ( string $context = 'view' ) : string Get discount_total.
get_fees ( ) : array Return an array of fees within this order.
get_formatted_line_subtotal ( array $item, string $tax_display = '' ) : string Gets line subtotal - formatted for display.
get_formatted_order_total ( ) : string Gets order total - formatted for display.
get_item ( integer $item_id ) : WC_Order_Item Get an order item object, based on it's type.
get_item_count ( string $item_type = '' ) : string Gets the count of order items of a certain type.
get_item_subtotal ( object $item, boolean $inc_tax = false, boolean $round = true ) : float Get item subtotal - this is the cost before discount.
get_item_tax ( mixed $item, boolean $round = true ) : float Get item tax - useful for gateways.
get_item_total ( object $item, boolean $inc_tax = false, boolean $round = true ) : float Calculate item cost - useful for gateways.
get_items ( string | array $types = 'line_item' ) : Array Return an array of items/products within this order.
get_items_tax_classes ( ) : array Get all tax classes for items in the order.
get_line_subtotal ( object $item, boolean $inc_tax = false, boolean $round = true ) : float Get line subtotal - this is the cost before discount.
get_line_tax ( mixed $item ) : float Get line tax - useful for gateways.
get_line_total ( object $item, boolean $inc_tax = false, boolean $round = true ) : float Calculate line total - useful for gateways.
get_order_item_totals ( mixed $tax_display = '' ) : array Get totals for display on pages and in emails.
get_parent_id ( string $context = 'view' ) : integer Get parent order ID.
get_payment_tokens ( ) : array Returns a list of all payment tokens associated with the current order
get_prices_include_tax ( string $context = 'view' ) : boolean Get prices_include_tax.
get_shipping_method ( ) : string Gets formatted shipping method title.
get_shipping_methods ( ) : array Return an array of shipping costs within this order.
get_shipping_tax ( string $context = 'view' ) : string Get shipping_tax.
get_shipping_to_display ( $tax_display = '' ) : string Gets shipping (formatted).
get_shipping_total ( string $context = 'view' ) : string Get shipping_total.
get_status ( string $context = 'view' ) : string Return the order statuses without wc- internal prefix.
get_subtotal ( ) : float Gets order subtotal.
get_subtotal_to_display ( boolean $compound = false, string $tax_display = '' ) : string Gets subtotal - subtotal is shown before discounts, but with localised taxes.
get_tax_totals ( ) : array Get taxes, merged by code, formatted ready for output.
get_taxes ( ) : array Return an array of taxes within this order.
get_total ( string $context = 'view' ) : float Gets order grand total. incl. taxes. Used in gateways.
get_total_discount ( boolean $ex_tax = true ) : float Gets the total discount amount.
get_total_tax ( string $context = 'view' ) : float Get total tax amount. Alias for get_order_tax().
get_type ( ) : string Get internal type.
get_used_coupons ( ) : array Get coupon codes only.
get_version ( string $context = 'view' ) : string Get order_version.
has_free_item ( ) : boolean Returns true if the order contains a free product.
has_shipping_method ( string $method_id ) : boolean Check whether this order has a specific shipping method or not.
has_status ( $status ) : boolean Checks the order status against a passed in status.
remove_item ( integer $item_id ) Remove item from the order.
remove_order_items ( string $type = null ) Remove all line items (products, coupons, shipping, taxes) from the order.
save ( ) : integer Save data to the database.
set_cart_tax ( string $value ) Set cart tax.
set_currency ( string $value ) Set order_currency.
set_date_created ( string $timestamp ) Set date_created.
set_date_modified ( string $timestamp ) Set date_modified.
set_discount_tax ( string $value ) Set discount_tax.
set_discount_total ( string $value ) Set discount_total.
set_parent_id ( integer $value ) Set parent order ID.
set_prices_include_tax ( boolean $value ) Set prices_include_tax.
set_shipping_tax ( string $value ) Set shipping_tax.
set_shipping_total ( string $value ) Set shipping_total.
set_status ( string $new_status ) : array Set order status.
set_total ( string $value, string $deprecated = '' ) Set total.
set_version ( string $value ) Set order_version.
update_taxes ( ) Update tax lines for the order based on the line item taxes themselves.

보호된 메소드들

메소드 설명
get_hook_prefix ( ) : string Prefix for action and filter hooks on data.
get_items_key ( $item ) : string Get key for where a certain item type is stored in _items.
save_items ( ) Save all order items which are part of this order.
set_total_tax ( string $value ) Sets order tax (sum of cart and shipping tax). Used internaly only.
type_to_group ( string $type ) : string Convert a type to a types group.

메소드 상세

__construct() 공개 메소드

This class should NOT be instantiated, but the get_order function or new WC_Order_Factory. should be used. It is possible, but the aforementioned are preferred and are the only. methods that will be maintained going forward.
public __construct ( integer | object | WC_Order $order )
$order integer | object | WC_Order Order to read.

add_item() 공개 메소드

Adds an order item to this order. The order item will not persist until save.
부터: 2.7.0
public add_item ( $item )

add_payment_token() 공개 메소드

Add a payment token to an order
부터: 2.6
public add_payment_token ( WC_Payment_Token $token ) : boolean | integer
$token WC_Payment_Token Payment token object
리턴 boolean | integer The new token ID or false if it failed.

add_product() 공개 메소드

Add a product line item to the order. This is the only line item type with it's own method because it saves looking up order amounts (costs are added up for you).
public add_product ( WC_Product $product, integer $qty = 1, array $args = [] ) : integer
$product WC_Product
$qty integer
$args array
리턴 integer order item ID

calculate_shipping() 공개 메소드

Calculate shipping total.
부터: 2.2
public calculate_shipping ( ) : float
리턴 float

calculate_taxes() 공개 메소드

Will use the base country unless customer addresses are set.
public calculate_taxes ( $args = [] )
$args array Added in 2.7.0 to pass things like location.

calculate_totals() 공개 메소드

Calculate totals by looking at the contents of the order. Stores the totals and returns the orders final total.
부터: 2.2
public calculate_totals ( boolean $and_taxes = true ) : float
$and_taxes boolean Calc taxes if true.
리턴 float calculated grand total.

get_cart_tax() 공개 메소드

Gets cart tax amount.
public get_cart_tax ( string $context = 'view' ) : float
$context string
리턴 float

get_currency() 공개 메소드

Gets order currency.
public get_currency ( string $context = 'view' ) : string
$context string
리턴 string

get_data() 공개 메소드

Get all class data in array format.
부터: 2.7.0
public get_data ( ) : array
리턴 array

get_date_created() 공개 메소드

Get date_created.
public get_date_created ( string $context = 'view' ) : integer
$context string
리턴 integer

get_date_modified() 공개 메소드

Get date_modified.
public get_date_modified ( string $context = 'view' ) : integer
$context string
리턴 integer

get_discount_tax() 공개 메소드

Get discount_tax.
public get_discount_tax ( string $context = 'view' ) : string
$context string
리턴 string

get_discount_to_display() 공개 메소드

Get the discount amount (formatted).
부터: 2.3.0
public get_discount_to_display ( $tax_display = '' ) : string
리턴 string

get_discount_total() 공개 메소드

Get discount_total.
public get_discount_total ( string $context = 'view' ) : string
$context string
리턴 string

get_fees() 공개 메소드

Return an array of fees within this order.
public get_fees ( ) : array
리턴 array

get_formatted_line_subtotal() 공개 메소드

Gets line subtotal - formatted for display.
public get_formatted_line_subtotal ( array $item, string $tax_display = '' ) : string
$item array
$tax_display string
리턴 string

get_formatted_order_total() 공개 메소드

Gets order total - formatted for display.

get_hook_prefix() 보호된 메소드

Prefix for action and filter hooks on data.
부터: 2.7.0
protected get_hook_prefix ( ) : string
리턴 string

get_item() 공개 메소드

Get an order item object, based on it's type.
부터: 2.7.0
public get_item ( integer $item_id ) : WC_Order_Item
$item_id integer
리턴 WC_Order_Item

get_item_count() 공개 메소드

Gets the count of order items of a certain type.
public get_item_count ( string $item_type = '' ) : string
$item_type string
리턴 string

get_item_subtotal() 공개 메소드

Get item subtotal - this is the cost before discount.
public get_item_subtotal ( object $item, boolean $inc_tax = false, boolean $round = true ) : float
$item object
$inc_tax boolean (default: false).
$round boolean (default: true).
리턴 float

get_item_tax() 공개 메소드

Get item tax - useful for gateways.
public get_item_tax ( mixed $item, boolean $round = true ) : float
$item mixed
$round boolean (default: true).
리턴 float

get_item_total() 공개 메소드

Calculate item cost - useful for gateways.
public get_item_total ( object $item, boolean $inc_tax = false, boolean $round = true ) : float
$item object
$inc_tax boolean (default: false).
$round boolean (default: true).
리턴 float

get_items() 공개 메소드

Return an array of items/products within this order.
public get_items ( string | array $types = 'line_item' ) : Array
$types string | array Types of line items to get (array or string).
리턴 Array of WC_Order_item

get_items_key() 보호된 메소드

Get key for where a certain item type is stored in _items.
부터: 2.7.0
protected get_items_key ( $item ) : string
$item object Order item (product, shipping, fee, coupon, tax)
리턴 string

get_items_tax_classes() 공개 메소드

Get all tax classes for items in the order.
부터: 2.6.3
public get_items_tax_classes ( ) : array
리턴 array

get_line_subtotal() 공개 메소드

Get line subtotal - this is the cost before discount.
public get_line_subtotal ( object $item, boolean $inc_tax = false, boolean $round = true ) : float
$item object
$inc_tax boolean (default: false).
$round boolean (default: true).
리턴 float

get_line_tax() 공개 메소드

Get line tax - useful for gateways.
public get_line_tax ( mixed $item ) : float
$item mixed
리턴 float

get_line_total() 공개 메소드

Calculate line total - useful for gateways.
public get_line_total ( object $item, boolean $inc_tax = false, boolean $round = true ) : float
$item object
$inc_tax boolean (default: false).
$round boolean (default: true).
리턴 float

get_order_item_totals() 공개 메소드

Get totals for display on pages and in emails.
public get_order_item_totals ( mixed $tax_display = '' ) : array
$tax_display mixed
리턴 array

get_parent_id() 공개 메소드

Get parent order ID.
부터: 2.7.0
public get_parent_id ( string $context = 'view' ) : integer
$context string
리턴 integer

get_payment_tokens() 공개 메소드

Returns a list of all payment tokens associated with the current order
부터: 2.6
public get_payment_tokens ( ) : array
리턴 array An array of payment token objects

get_prices_include_tax() 공개 메소드

Get prices_include_tax.
public get_prices_include_tax ( string $context = 'view' ) : boolean
$context string
리턴 boolean

get_shipping_method() 공개 메소드

Gets formatted shipping method title.
public get_shipping_method ( ) : string
리턴 string

get_shipping_methods() 공개 메소드

Return an array of shipping costs within this order.
public get_shipping_methods ( ) : array
리턴 array

get_shipping_tax() 공개 메소드

Get shipping_tax.
public get_shipping_tax ( string $context = 'view' ) : string
$context string
리턴 string

get_shipping_to_display() 공개 메소드

Gets shipping (formatted).
public get_shipping_to_display ( $tax_display = '' ) : string
리턴 string

get_shipping_total() 공개 메소드

Get shipping_total.
public get_shipping_total ( string $context = 'view' ) : string
$context string
리턴 string

get_status() 공개 메소드

Return the order statuses without wc- internal prefix.
public get_status ( string $context = 'view' ) : string
$context string
리턴 string

get_subtotal() 공개 메소드

Gets order subtotal.
public get_subtotal ( ) : float
리턴 float

get_subtotal_to_display() 공개 메소드

Gets subtotal - subtotal is shown before discounts, but with localised taxes.
public get_subtotal_to_display ( boolean $compound = false, string $tax_display = '' ) : string
$compound boolean (default: false).
$tax_display string (default: the tax_display_cart value).
리턴 string

get_tax_totals() 공개 메소드

Get taxes, merged by code, formatted ready for output.
public get_tax_totals ( ) : array
리턴 array

get_taxes() 공개 메소드

Return an array of taxes within this order.
public get_taxes ( ) : array
리턴 array

get_total() 공개 메소드

Gets order grand total. incl. taxes. Used in gateways.
public get_total ( string $context = 'view' ) : float
$context string
리턴 float

get_total_discount() 공개 메소드

Gets the total discount amount.
public get_total_discount ( boolean $ex_tax = true ) : float
$ex_tax boolean Show discount excl any tax.
리턴 float

get_total_tax() 공개 메소드

Get total tax amount. Alias for get_order_tax().
public get_total_tax ( string $context = 'view' ) : float
$context string
리턴 float

get_type() 공개 메소드

Get internal type.
public get_type ( ) : string
리턴 string

get_used_coupons() 공개 메소드

Get coupon codes only.
public get_used_coupons ( ) : array
리턴 array

get_version() 공개 메소드

Get order_version.
public get_version ( string $context = 'view' ) : string
$context string
리턴 string

has_free_item() 공개 메소드

Returns true if the order contains a free product.
부터: 2.5.0
public has_free_item ( ) : boolean
리턴 boolean

has_shipping_method() 공개 메소드

Check whether this order has a specific shipping method or not.
public has_shipping_method ( string $method_id ) : boolean
$method_id string
리턴 boolean

has_status() 공개 메소드

Checks the order status against a passed in status.
public has_status ( $status ) : boolean
리턴 boolean

remove_item() 공개 메소드

Remove item from the order.
public remove_item ( integer $item_id )
$item_id integer

remove_order_items() 공개 메소드

Remove all line items (products, coupons, shipping, taxes) from the order.
public remove_order_items ( string $type = null )
$type string Order item type. Default null.

save() 공개 메소드

Save data to the database.
부터: 2.7.0
public save ( ) : integer
리턴 integer order ID

save_items() 보호된 메소드

Save all order items which are part of this order.
protected save_items ( )

set_cart_tax() 공개 메소드

Set cart tax.
public set_cart_tax ( string $value )
$value string

set_currency() 공개 메소드

Set order_currency.
public set_currency ( string $value )
$value string

set_date_created() 공개 메소드

Set date_created.
public set_date_created ( string $timestamp )
$timestamp string Timestamp

set_date_modified() 공개 메소드

Set date_modified.
public set_date_modified ( string $timestamp )
$timestamp string

set_discount_tax() 공개 메소드

Set discount_tax.
public set_discount_tax ( string $value )
$value string

set_discount_total() 공개 메소드

Set discount_total.
public set_discount_total ( string $value )
$value string

set_parent_id() 공개 메소드

Set parent order ID.
부터: 2.7.0
public set_parent_id ( integer $value )
$value integer

set_prices_include_tax() 공개 메소드

Set prices_include_tax.
public set_prices_include_tax ( boolean $value )
$value boolean

set_shipping_tax() 공개 메소드

Set shipping_tax.
public set_shipping_tax ( string $value )
$value string

set_shipping_total() 공개 메소드

Set shipping_total.
public set_shipping_total ( string $value )
$value string

set_status() 공개 메소드

Set order status.
부터: 2.7.0
public set_status ( string $new_status ) : array
$new_status string Status to change the order to. No internal wc- prefix is required.
리턴 array details of change

set_total() 공개 메소드

Set total.
public set_total ( string $value, string $deprecated = '' )
$value string
$deprecated string Function used to set different totals based on this.

set_total_tax() 보호된 메소드

Sets order tax (sum of cart and shipping tax). Used internaly only.
protected set_total_tax ( string $value )
$value string

set_version() 공개 메소드

Set order_version.
public set_version ( string $value )
$value string

type_to_group() 보호된 메소드

Convert a type to a types group.
protected type_to_group ( string $type ) : string
$type string
리턴 string group

update_taxes() 공개 메소드

Update tax lines for the order based on the line item taxes themselves.
public update_taxes ( )

프로퍼티 상세

$cache_group 보호되어 있는 프로퍼티

A group must be set to to enable caching.
protected string $cache_group
리턴 string

$data 보호되어 있는 프로퍼티

Notes: cart_tax = cart_tax is the new name for the legacy 'order_tax' which is the tax for items only, not shipping.
부터: 2.7.0
protected array $data
리턴 array

$data_store_name 보호되어 있는 프로퍼티

Which data store to load.
protected string $data_store_name
리턴 string

$items 보호되어 있는 프로퍼티

Order items will be stored here, sometimes before they persist in the DB.
부터: 2.7.0
protected array $items
리턴 array

$items_to_delete 보호되어 있는 프로퍼티

Order items that need deleting are stored here.
부터: 2.7.0
protected array $items_to_delete
리턴 array