Automattic\WooCommerce\StoreApi\Routes\V1

ProductAttributes{}WC 1.0

ProductAttributes class.

No Hooks.

Usage

$ProductAttributes = new ProductAttributes();
// use class methods

Methods

  1. ERROR: no method name found on line ``
  2. public get_args()
  3. public wc_get_attribute( $id )
  4. ERROR: no method name found on line ``
  5. ERROR: no method name found on line ``
  6. ERROR: no method name found on line ``
  7. public get_path()
  8. protected get_route_response( \WP_REST_Request $request )
  9. ERROR: no method name found on line `/**`

ProductAttributes{} code WC 8.6.1

class ProductAttributes extends AbstractRoute {
	/**
	 * The route identifier.
	 *
	 * @var string
	 */
	const IDENTIFIER = 'product-attributes';

	/**
	 * The routes schema.
	 *
	 * @var string
	 */
	const SCHEMA_TYPE = 'product-attribute';

	/**
	 * Get the path of this REST route.
	 *
	 * @return string
	 */
	public function get_path() {
		return '/products/attributes';
	}

	/**
	 * Get method arguments for this REST route.
	 *
	 * @return array An array of endpoints.
	 */
	public function get_args() {
		return [
			[
				'methods'             => \WP_REST_Server::READABLE,
				'callback'            => [ $this, 'get_response' ],
				'permission_callback' => '__return_true',
				'args'                => $this->get_collection_params(),
			],
			'schema' => [ $this->schema, 'get_public_item_schema' ],
		];
	}

	/**
	 * Get a collection of attributes.
	 *
	 * @param \WP_REST_Request $request Request object.
	 * @return \WP_REST_Response
	 */
	protected function get_route_response( \WP_REST_Request $request ) {
		$ids    = wc_get_attribute_taxonomy_ids();
		$return = [];

		foreach ( $ids as $id ) {
			$object   = wc_get_attribute( $id );
			$data     = $this->prepare_item_for_response( $object, $request );
			$return[] = $this->prepare_response_for_collection( $data );
		}

		return rest_ensure_response( $return );
	}
}