WordPress at a glance
function is not described

WC_API_Products::get_product_shipping_classes() public WC 2.5.0

Get a listing of product shipping classes.

{} It's a method of the class: WC_API_Products{}

Return

Array|WP_Error. List of product shipping classes if succeed, otherwise WP_Error will be returned

Usage

$WC_API_Products = new WC_API_Products();
$WC_API_Products->get_product_shipping_classes( $fields );
$fields(string|null)
Fields to limit response to

Changelog

Since 2.5.0 Introduced.

Code of WC_API_Products::get_product_shipping_classes() WC 5.0.0

<?php
public function get_product_shipping_classes( $fields = null ) {
	try {
		// Permissions check
		if ( ! current_user_can( 'manage_product_terms' ) ) {
			throw new WC_API_Exception( 'woocommerce_api_user_cannot_read_product_shipping_classes', __( 'You do not have permission to read product shipping classes', 'woocommerce' ), 401 );
		}

		$product_shipping_classes = array();

		$terms = get_terms( 'product_shipping_class', array( 'hide_empty' => false, 'fields' => 'ids' ) );

		foreach ( $terms as $term_id ) {
			$product_shipping_classes[] = current( $this->get_product_shipping_class( $term_id, $fields ) );
		}

		return array( 'product_shipping_classes' => apply_filters( 'woocommerce_api_product_shipping_classes_response', $product_shipping_classes, $terms, $fields, $this ) );
	} catch ( WC_API_Exception $e ) {
		return new WP_Error( $e->getErrorCode(), $e->getMessage(), array( 'status' => $e->getCode() ) );
	}
}