Automattic\WooCommerce\StoreApi\Utilities

CartController::get_package_name()protectedWC 1.0

Creates a name for a package.

Method of the class: CartController{}

Hooks from the method

Return

String.

Usage

// protected - for code of main (parent) or child class
$result = $this->get_package_name( $package, $index );
$package(array) (required)
Shipping package from WooCommerce.
$index(int) (required)
Package number.

CartController::get_package_name() code WC 9.0.1

protected function get_package_name( $package, $index ) {
	/**
	 * Filters the shipping package name.
	 *
	 * @since 4.3.0
	 *
	 * @internal Matches filter name in WooCommerce core.
	 *
	 * @param string $shipping_package_name Shipping package name.
	 * @param string $package_id Shipping package ID.
	 * @param array $package Shipping package from WooCommerce.
	 * @return string Shipping package name.
	 */
	return apply_filters(
		'woocommerce_shipping_package_name',
		$index > 1 ?
			sprintf(
				/* translators: %d: shipping package number */
				_x( 'Shipment %d', 'shipping packages', 'woocommerce' ),
				$index
			) :
			_x( 'Shipment 1', 'shipping packages', 'woocommerce' ),
		$package['package_id'],
		$package
	);
}