XStore Brands API

Brands (eteheme_brands) #

The schema defines all the fields that exist within a brand record. Any response from these endpoints can be expected to contain the fields below unless the _filter query parameter is used or the schema field only appears in a specific context.

Schema #

id
(integer)
Unique identifier for the term.

Read-only

Context:
view, embed, edit
count
(integer)
The number of published posts for the term.

Read-only

Context:
view, edit
description
(string)
HTML description of the term.

Context:
view, edit
link
(string, URI)
URL of the term.

Read-only

Context:
view, embed, edit
name
(string) 
HTML title for the term.

Context:
view, embed, edit
slug
(string) 
An alphanumeric identifier for the term unique to its type.

Context:
view, embed, edit
taxonomy
(string)
Type attribution for the term.

Read-only

Context:
view, embed, edit
One of: category, post_tag, nav_menu, link_category, post_format
parent
(integer)
The parent term ID.

Context:
view, edit
meta
(object, array)
Meta fields.

Context:
view, edit

List Brands #

Query this endpoint to retrieve a collection of brands. The response you receive can be controlled and filtered using the URL query parameters below.

Definition  #

GET /wp/v2/etheme_brands

Example Request #

$ curl <a href="https://example.com/wp-json/wp/v2/etheme_brands">https://example.com/wp-json/wp/v2/etheme_brands</a>

Example URL #

https://example.com/wp-json/wp/v2/etheme_brands

Arguments  #

context

The scope under which the request is made; determines the fields present in the response.

Default: view

One of: view, embed, edit

page

Current page of the collection.

Default: 1

per_page

Maximum number of items to be returned in result set.

Default: 10

search Limit results to those matching a string.
exclude Ensure the result set excludes specific IDs.
include Limit result set to specific IDs.
order

Order sort attribute ascending or descending.

Default: asc

One of: asc, desc

orderby

Sort collection by term attribute.

Default: name

One of: id, include, name, slug, include_slugs, term_group, description, count

hide_empty Whether to hide terms not assigned to any posts.
parent Limit result set to terms assigned to a specific parent.
post Limit results set to terms assigned to a specific post.
slug Limit results set to terms with one or more specific slugs.

Create a Brand #

Definition #

POST /wp/v2/etheme_brands

Example Request from curl (in progress) #

$ curl <a href="https://example.com/wp-json/wp/v2/etheme_brands">https://example.com/wp-json/wp/v2/etheme_brands</a>

Example Request from wp #

$meta = (object) array(
	'some_meta' => 'value'
);
$image = array(
	'src'         => 'https://example.com/woocommerce/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
	'alt'         => 'some alt',
    'title'       => 'some title',
    'caption'     => 'some caption',
    'description' => 'some description'
);
$api_response = wp_remote_post( 'https://example.com/wp-json/wp/v2/etheme_brands', array(
	'headers' => array(
		'Authorization' => 'Basic ' . base64_encode( 'user_name:user_password' )
	),
	'body' => array(
		'name'        => 'example brand',
        'slug'        => 'example-brand',
        'description' => 'some description',
        'meta'        => $meta,
        'image'       => $image
	)
) );

Arguments #

description

(string)

HTML description of the Brand.

name

(string)

HTML title for the term.

Required: 1(true)

slug

(string)

An alphanumeric identifier for the term unique to its type.

parent

(integer)

The parent term ID.

meta

(array, object)

Meta fields.

image

(array, object)

image data for brand

src (string); Required: 1(true)

alt (string)

title (string)

caption (string)

description (string)

Example array:

$image = array(
	'src'         => 'https://example.com/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
	'alt'         => 'alt text',
	'title'       => 'title text',
	'caption'     => 'caption ',
	'description' => 'description'
);

Retrieve a Brand #

Definition & Example Request #

GET /wp/v2/etheme_brands/{brand_id}

Example Request #

$ curl <a href="https://example.com/wp-json/wp/v2/etheme_brands{brand_id}">https://example.com/wp-json/wp/v2/etheme_brands{brand_id}</a>

Example URL #

https://example.com/wp-json/wp/v2/etheme_brands{brand_id}

Arguments  #

id Unique identifier for the term.
context

Scope under which the request is made; determines the fields present in the response.

Default: view

One of: view, embed, edit

Update a Brand #

Definition #

POST /wp/v2/etheme_brands/id

Example Request from curl (in progress) #

$ curl <a href="https://example.com/wp-json/wp/v2/etheme_brands/id">https://example.com/wp-json/wp/v2/etheme_brands/id</a>

Example Request from WP #

$meta = (object) array(
	'some_meta' => 'value'
);

$image = array(
	'src'         => 'https://example.com/wp-content/uploads/sites/56/2013/06/T_2_back.jpg',
	'alt'         => 'some alt',
    'title'       => 'some title',
    'caption'     => 'some caption',
    'description' => 'some description'
);

$api_response = wp_remote_post( 'https://example.com/wp-json/wp/v2/etheme_brands/id', array(
	'headers' => array(
		'Authorization' => 'Basic ' . base64_encode( 'user_name:user_password' )
	),
	'body' => array(
		'name'        => 'new example brand',
        'slug'        => 'new-example-brand',
        'description' => 'new some description',
        'meta'        => $meta,
        'image'       => $image
	)
) );

To prevent uploading and setup the same image just remove the image param. If you want to change the image that already exists modify mata param:

$meta = (object) array(
	'thumbnail_id' => 5054, // ID of image in media library
);

Arguments  #

id Unique identifier for the term.
description HTML description of the term.
name HTML title for the term.
slug An alphanumeric identifier for the term unique to its type.
parent The parent term ID.
meta Meta fields.

Delete a Brand #

Definition  #

POST DELETE /wp/v2/etheme_brands/id

Example Request #

$ curl -X  DELETEhttps://example.com/wp-json/wp/v2/etheme_brands/id

Example Request from WP #

$api_response = wp_remote_post( 'https://example.com/wp-json/wp/v2/etheme_brands/id', array(
	'method'    => 'DELETE',
	'headers' => array(
		'Authorization' => 'Basic ' . base64_encode( 'user_name:user_password' )
	),
	'body' => array(
        'force' => true,
	)
) );

or

$api_response = wp_remote_post( 'https://example.com/wp-json/wp/v2/etheme_brands/id?force=true', array(
	'method'    => 'DELETE',
	'headers' => array(
		'Authorization' => 'Basic ' . base64_encode( 'user_name:user_password' )
	),
) );

Arguments  #

id Unique identifier for the term.
force Required to be true, Brands do not support trashing.

To setup product brands for products, you can use the default WooCommerce Rest API and add to request etheme_brands param: etheme_brands (array)

For example when creating the product

$api_response = wp_remote_post( 'https://example.com/wp-json/wc/v3/products/', array(
			'method'    => 'POST',
			'headers' => array(
				'Authorization' => 'Basic ' . base64_encode( 'consumer_key:consumer_secret' )
			),
			'body' => array(
				'name' => 'Premium Quality aaaaaaaaa',
				"regular_price" => "21.99",
		        "description" => "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
		        "short_description" => "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas.",
				'etheme_brands' => array(45,48),
				"images" => array(array("src"=> "https://example.com/wp-content/uploads/sites/56/2013/06/T_2_front.jpg"),
		        ),
			)
		) );

For example when updating the product

$api_response = wp_remote_post( 'https://example.com/wp-json/wc/v3/products/4953', array(
		'method'    => 'POST',
		'headers' => array(
			'Authorization' => 'Basic ' . base64_encode( 'consumer_key:consumer_secret' )
		),
		'body' => array(
	        "description" => "Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Vestibulum tortor quam, feugiat vitae, ultricies eget, tempor sit amet, ante. Donec eu libero sit amet quam egestas semper. Aenean ultricies mi vitae est. Mauris placerat eleifend leo.",
			'etheme_brands' => array(45,48),
		)
	) );
Updated on September 26, 2024
Was this Article helpful?