PHP 클래스 WC_API_Products

상속: extends WC_API_Resource
파일 보기 프로젝트 열기: woocommerce/woocommerce 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$base string the route base

공개 메소드들

메소드 설명
bulk ( array $data ) : array Bulk update or insert products Accepts an array with products in the formats supported by WC_API_Products->create_product() and WC_API_Products->edit_product()
create_product ( array $data ) : array Create a new product
create_product_attribute ( array $data ) : array Create a new product attribute
create_product_attribute_term ( integer $attribute_id, array $data ) : array Create a new product attribute term.
create_product_category ( array $data ) : array | WP_Error Create a new product category.
create_product_shipping_class ( array $data ) : array | WP_Error Create a new product shipping class.
create_product_tag ( array $data ) : array | WP_Error Create a new product tag.
delete_product ( integer $id, boolean $force = false ) : array Delete a product
delete_product_attribute ( integer $id ) : array Delete a product attribute
delete_product_attribute_term ( integer $attribute_id, integer $id ) : array Delete a product attribute term.
delete_product_category ( integer $id ) : array | WP_Error Delete a product category.
delete_product_shipping_class ( integer $id ) : array | WP_Error Delete a product shipping class.
delete_product_tag ( integer $id ) : array | WP_Error Delete a product tag.
edit_product ( integer $id, array $data ) : array Edit a product
edit_product_attribute ( integer $id, array $data ) : array Edit a product attribute
edit_product_attribute_term ( integer $attribute_id, integer $id, array $data ) : array Edit a product attribute term.
edit_product_category ( integer $id, array $data ) : array | WP_Error Edit a product category.
edit_product_shipping_class ( integer $id, array $data ) : array | WP_Error Edit a product shipping class.
edit_product_tag ( integer $id, array $data ) : array | WP_Error Edit a product tag.
get_product ( integer $id, string $fields = null ) : array Get the product for the given ID
get_product_attribute ( string $id, string | null $fields = null ) : array Get the product attribute for the given ID
get_product_attribute_term ( integer $attribute_id, string $id, string | null $fields = null ) : array Get the product attribute term for the given ID.
get_product_attribute_terms ( integer $attribute_id, string | null $fields = null ) : array Get a listing of product attribute terms.
get_product_attributes ( string | null $fields = null ) : array Get a listing of product attributes
get_product_by_sku ( integer $sku, string $fields = null ) : array Get product by SKU
get_product_categories ( string | null $fields = null ) : array Get a listing of product categories
get_product_category ( string $id, string | null $fields = null ) : array Get the product category for the given ID
get_product_orders ( integer $id, $fields = null, string $filter = [], string $status = null, $page = 1 ) : array Get the orders for a product
get_product_reviews ( integer $id, string $fields = null ) : array Get the reviews for a product
get_product_shipping_class ( string $id, string | null $fields = null ) : array | WP_Error Get the product shipping class for the given ID.
get_product_shipping_classes ( string | null $fields = null ) : array | WP_Error Get a listing of product shipping classes.
get_product_tag ( string $id, string | null $fields = null ) : array Get the product tag for the given ID.
get_product_tags ( string | null $fields = null ) : array Get a listing of product tags.
get_products ( string $fields = null, string $type = null, array $filter = [], integer $page = 1 ) : array Get all products
get_products_count ( string $type = null, array $filter = [] ) : array Get the total number of orders
register_routes ( array $routes ) : array Register the routes for this class
upload_product_category_image ( string $image_url ) : integer | WP_Error Upload product category image from URL.
upload_product_image ( string $image_url ) : integer | WP_Error Upload image from URL

보호된 메소드들

메소드 설명
clear_product ( $product_id ) Clear product
get_attribute_options ( integer $product_id, array $attribute ) : array Get attribute options.
save_default_attributes ( WC_Product $product, WP_REST_Request $request ) : WC_Product Save default attributes.
save_default_attributes ( WC_Product $product, array $request ) : WC_Product Save default attributes.
save_product_images ( WC_Product $product, array $images ) Save product images
save_product_images ( WC_Product $product, array $images ) : WC_Product Save product images.
save_product_meta ( WC_Product $product, array $data ) : WC_Product Save product meta
save_variations ( WC_Product $product, array $request ) : WC_Product Save variations
set_product_category_image_as_attachment ( integer $upload ) : integer Sets uploaded category image as attachment and returns the attachment ID.
set_product_image_as_attachment ( array $upload, integer $id ) : integer Sets product image as attachment and returns the attachment ID.
set_uploaded_image_as_attachment ( array $upload, integer $id ) : integer Set uploaded image as attachment.
upload_image_from_url ( string $image_url, string $upload_for = 'product_image' ) : integer | WP_Error Upload image from URL.
validate_attribute_data ( string $name, string $slug, string $type, string $order_by, boolean $new_data = true ) : boolean Validate attribute data.

비공개 메소드들

메소드 설명
get_attribute_taxonomy_by_slug ( string $slug ) : string | null Get attribute taxonomy by slug.
get_attributes ( WC_Product | WC_Product_Variation $product ) : array Get the attributes for a product or product variation
get_downloads ( WC_Product | WC_Product_Variation $product ) : array Get the downloads for a product or product variation
get_grouped_products_data ( WC_Product $product ) : array Get grouped products data
get_images ( WC_Product | WC_Product_Variation $product ) : array Get the images for a product or product variation
get_product_data ( WC_Product $product ) : WC_Product Get standard product data that applies to every product type
get_product_data ( WC_Product $product ) : array Get standard product data that applies to every product type
get_product_menu_order ( WC_Product $product ) : integer Get product menu order.
get_variation_data ( WC_Product $product ) : array Get an individual variation's data
query_products ( array $args ) : WP_Query Helper method to get product post objects
save_downloadable_files ( WC_Product $product, array $downloads, integer $deprecated ) : WC_Product Save downloadable files
save_product_shipping_data ( WC_Product $product, array $data ) : WC_Product Save product shipping data

메소드 상세

bulk() 공개 메소드

Bulk update or insert products Accepts an array with products in the formats supported by WC_API_Products->create_product() and WC_API_Products->edit_product()
부터: 2.4.0
public bulk ( array $data ) : array
$data array
리턴 array

clear_product() 보호된 메소드

Clear product
protected clear_product ( $product_id )

create_product() 공개 메소드

Create a new product
부터: 2.2
public create_product ( array $data ) : array
$data array posted data
리턴 array

create_product_attribute() 공개 메소드

Create a new product attribute
부터: 2.4.0
public create_product_attribute ( array $data ) : array
$data array posted data
리턴 array

create_product_attribute_term() 공개 메소드

Create a new product attribute term.
부터: 2.5.0
public create_product_attribute_term ( integer $attribute_id, array $data ) : array
$attribute_id integer Attribute ID.
$data array Posted data.
리턴 array

create_product_category() 공개 메소드

Create a new product category.
부터: 2.5.0
public create_product_category ( array $data ) : array | WP_Error
$data array Posted data
리턴 array | WP_Error Product category if succeed, otherwise WP_Error will be returned

create_product_shipping_class() 공개 메소드

Create a new product shipping class.
부터: 2.5.0
public create_product_shipping_class ( array $data ) : array | WP_Error
$data array Posted data
리턴 array | WP_Error Product shipping class if succeed, otherwise WP_Error will be returned

create_product_tag() 공개 메소드

Create a new product tag.
부터: 2.5.0
public create_product_tag ( array $data ) : array | WP_Error
$data array Posted data
리턴 array | WP_Error Product tag if succeed, otherwise WP_Error will be returned

delete_product() 공개 메소드

Delete a product
public delete_product ( integer $id, boolean $force = false ) : array
$id integer the product ID
$force boolean true to permanently delete order, false to move to trash
리턴 array

delete_product_attribute() 공개 메소드

Delete a product attribute
부터: 2.4.0
public delete_product_attribute ( integer $id ) : array
$id integer the product attribute ID
리턴 array

delete_product_attribute_term() 공개 메소드

Delete a product attribute term.
부터: 2.5.0
public delete_product_attribute_term ( integer $attribute_id, integer $id ) : array
$attribute_id integer Attribute ID.
$id integer the product attribute ID.
리턴 array

delete_product_category() 공개 메소드

Delete a product category.
부터: 2.5.0
public delete_product_category ( integer $id ) : array | WP_Error
$id integer Product category term ID
리턴 array | WP_Error Success message if succeed, otherwise WP_Error will be returned

delete_product_shipping_class() 공개 메소드

Delete a product shipping class.
부터: 2.5.0
public delete_product_shipping_class ( integer $id ) : array | WP_Error
$id integer Product shipping class term ID
리턴 array | WP_Error Success message if succeed, otherwise WP_Error will be returned

delete_product_tag() 공개 메소드

Delete a product tag.
부터: 2.5.0
public delete_product_tag ( integer $id ) : array | WP_Error
$id integer Product tag term ID
리턴 array | WP_Error Success message if succeed, otherwise WP_Error will be returned

edit_product() 공개 메소드

Edit a product
public edit_product ( integer $id, array $data ) : array
$id integer the product ID
$data array
리턴 array

edit_product_attribute() 공개 메소드

Edit a product attribute
부터: 2.4.0
public edit_product_attribute ( integer $id, array $data ) : array
$id integer the attribute ID
$data array
리턴 array

edit_product_attribute_term() 공개 메소드

Edit a product attribute term.
부터: 2.5.0
public edit_product_attribute_term ( integer $attribute_id, integer $id, array $data ) : array
$attribute_id integer Attribute ID.
$id integer the attribute ID.
$data array
리턴 array

edit_product_category() 공개 메소드

Edit a product category.
부터: 2.5.0
public edit_product_category ( integer $id, array $data ) : array | WP_Error
$id integer Product category term ID
$data array Posted data
리턴 array | WP_Error Product category if succeed, otherwise WP_Error will be returned

edit_product_shipping_class() 공개 메소드

Edit a product shipping class.
부터: 2.5.0
public edit_product_shipping_class ( integer $id, array $data ) : array | WP_Error
$id integer Product shipping class term ID
$data array Posted data
리턴 array | WP_Error Product shipping class if succeed, otherwise WP_Error will be returned

edit_product_tag() 공개 메소드

Edit a product tag.
부터: 2.5.0
public edit_product_tag ( integer $id, array $data ) : array | WP_Error
$id integer Product tag term ID
$data array Posted data
리턴 array | WP_Error Product tag if succeed, otherwise WP_Error will be returned

get_attribute_options() 보호된 메소드

Get attribute options.
protected get_attribute_options ( integer $product_id, array $attribute ) : array
$product_id integer
$attribute array
리턴 array

get_product() 공개 메소드

Get the product for the given ID
부터: 2.1
public get_product ( integer $id, string $fields = null ) : array
$id integer the product ID
$fields string
리턴 array

get_product_attribute() 공개 메소드

Get the product attribute for the given ID
부터: 2.4.0
public get_product_attribute ( string $id, string | null $fields = null ) : array
$id string product attribute term ID
$fields string | null fields to limit response to
리턴 array

get_product_attribute_term() 공개 메소드

Get the product attribute term for the given ID.
부터: 2.5.0
public get_product_attribute_term ( integer $attribute_id, string $id, string | null $fields = null ) : array
$attribute_id integer Attribute ID.
$id string Product attribute term ID.
$fields string | null Fields to limit response to.
리턴 array

get_product_attribute_terms() 공개 메소드

Get a listing of product attribute terms.
부터: 2.5.0
public get_product_attribute_terms ( integer $attribute_id, string | null $fields = null ) : array
$attribute_id integer Attribute ID.
$fields string | null Fields to limit response to.
리턴 array

get_product_attributes() 공개 메소드

Get a listing of product attributes
부터: 2.4.0
public get_product_attributes ( string | null $fields = null ) : array
$fields string | null fields to limit response to
리턴 array

get_product_by_sku() 공개 메소드

Get product by SKU
사용 중단: 2.4.0
부터: 2.3.0
public get_product_by_sku ( integer $sku, string $fields = null ) : array
$sku integer the product SKU
$fields string
리턴 array

get_product_categories() 공개 메소드

Get a listing of product categories
부터: 2.2
public get_product_categories ( string | null $fields = null ) : array
$fields string | null fields to limit response to
리턴 array

get_product_category() 공개 메소드

Get the product category for the given ID
부터: 2.2
public get_product_category ( string $id, string | null $fields = null ) : array
$id string product category term ID
$fields string | null fields to limit response to
리턴 array

get_product_orders() 공개 메소드

Get the orders for a product
부터: 2.4.0
public get_product_orders ( integer $id, $fields = null, string $filter = [], string $status = null, $page = 1 ) : array
$id integer the product ID to get orders for
$filter string filters to include in response
$status string the order status to retrieve
$page $page page to retrieve
리턴 array

get_product_reviews() 공개 메소드

Get the reviews for a product
부터: 2.1
public get_product_reviews ( integer $id, string $fields = null ) : array
$id integer the product ID to get reviews for
$fields string fields to include in response
리턴 array

get_product_shipping_class() 공개 메소드

Get the product shipping class for the given ID.
부터: 2.5.0
public get_product_shipping_class ( string $id, string | null $fields = null ) : array | WP_Error
$id string Product shipping class term ID
$fields string | null Fields to limit response to
리턴 array | WP_Error Product shipping class if succeed, otherwise WP_Error will be returned

get_product_shipping_classes() 공개 메소드

Get a listing of product shipping classes.
부터: 2.5.0
public get_product_shipping_classes ( string | null $fields = null ) : array | WP_Error
$fields string | null Fields to limit response to
리턴 array | WP_Error List of product shipping classes if succeed, otherwise WP_Error will be returned

get_product_tag() 공개 메소드

Get the product tag for the given ID.
부터: 2.5.0
public get_product_tag ( string $id, string | null $fields = null ) : array
$id string Product tag term ID
$fields string | null Fields to limit response to
리턴 array Product tag

get_product_tags() 공개 메소드

Get a listing of product tags.
부터: 2.5.0
public get_product_tags ( string | null $fields = null ) : array
$fields string | null Fields to limit response to
리턴 array Product tags

get_products() 공개 메소드

Get all products
부터: 2.1
public get_products ( string $fields = null, string $type = null, array $filter = [], integer $page = 1 ) : array
$fields string
$type string
$filter array
$page integer
리턴 array

get_products_count() 공개 메소드

Get the total number of orders
부터: 2.1
public get_products_count ( string $type = null, array $filter = [] ) : array
$type string
$filter array
리턴 array

register_routes() 공개 메소드

GET /products GET /products/count GET /products/ GET /products//reviews
부터: 2.1
public register_routes ( array $routes ) : array
$routes array
리턴 array

save_default_attributes() 보호된 메소드

Save default attributes.
부터: 2.7.0
protected save_default_attributes ( WC_Product $product, WP_REST_Request $request ) : WC_Product
$product WC_Product
$request WP_REST_Request
리턴 WC_Product

save_default_attributes() 보호된 메소드

Save default attributes.
부터: 2.7.0
protected save_default_attributes ( WC_Product $product, array $request ) : WC_Product
$product WC_Product
$request array
리턴 WC_Product

save_product_images() 보호된 메소드

Save product images
부터: 2.2
protected save_product_images ( WC_Product $product, array $images )
$product WC_Product
$images array

save_product_images() 보호된 메소드

Save product images.
부터: 2.2
protected save_product_images ( WC_Product $product, array $images ) : WC_Product
$product WC_Product
$images array
리턴 WC_Product

save_product_meta() 보호된 메소드

Save product meta
부터: 2.2
protected save_product_meta ( WC_Product $product, array $data ) : WC_Product
$product WC_Product
$data array
리턴 WC_Product

save_variations() 보호된 메소드

Save variations
부터: 2.2
protected save_variations ( WC_Product $product, array $request ) : WC_Product
$product WC_Product
$request array
리턴 WC_Product

set_product_category_image_as_attachment() 보호된 메소드

Sets uploaded category image as attachment and returns the attachment ID.
부터: 2.5.0
protected set_product_category_image_as_attachment ( integer $upload ) : integer
$upload integer Upload information from wp_upload_bits
리턴 integer Attachment ID

set_product_image_as_attachment() 보호된 메소드

Sets product image as attachment and returns the attachment ID.
부터: 2.2
protected set_product_image_as_attachment ( array $upload, integer $id ) : integer
$upload array
$id integer
리턴 integer

set_uploaded_image_as_attachment() 보호된 메소드

Set uploaded image as attachment.
부터: 2.5.0
protected set_uploaded_image_as_attachment ( array $upload, integer $id ) : integer
$upload array Upload information from wp_upload_bits
$id integer Post ID. Default to 0.
리턴 integer Attachment ID

upload_image_from_url() 보호된 메소드

Upload image from URL.
부터: 2.5.0
protected upload_image_from_url ( string $image_url, string $upload_for = 'product_image' ) : integer | WP_Error
$image_url string
$upload_for string
리턴 integer | WP_Error Attachment id

upload_product_category_image() 공개 메소드

Upload product category image from URL.
부터: 2.5.0
public upload_product_category_image ( string $image_url ) : integer | WP_Error
$image_url string
리턴 integer | WP_Error attachment id

upload_product_image() 공개 메소드

Upload image from URL
부터: 2.2
public upload_product_image ( string $image_url ) : integer | WP_Error
$image_url string
리턴 integer | WP_Error attachment id

validate_attribute_data() 보호된 메소드

Validate attribute data.
부터: 2.4.0
protected validate_attribute_data ( string $name, string $slug, string $type, string $order_by, boolean $new_data = true ) : boolean
$name string
$slug string
$type string
$order_by string
$new_data boolean
리턴 boolean

프로퍼티 상세

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

the route base
protected string $base
리턴 string