Inventory_Presser_Taxonomies::get_hours( int $term_id )

get_hours


Description Description

Loads sets of hours from post meta into an array.


Top ↑

Parameters Parameters

$term_id

(int) (Required) The location term ID from which to extract hours


Top ↑

Return Return

(array) An array of hours arrays


Top ↑

Source Source

File: includes/class-taxonomies.php

	public static function get_hours( $term_id )
	{
		$hours = array();
		$term_meta = get_term_meta( $term_id );

		for( $h=1; $h<=self::LOCATION_MAX_HOURS; $h++ )
		{
			//Are there hours in this slot?
			if( empty( $term_meta['hours_' . $h . '_uid'][0] ) )
			{
				//No, we're done with this location
				break;
			}

			$set = array(
				'uid'   => $term_meta['hours_' . $h . '_uid'][0],
				'title' => self::meta_array_value_single( $term_meta, 'hours_' . $h . '_title' ),
			);

			$days = array_keys( INVP::weekdays() );
			for( $d=0; $d<7; $d++ )
			{
				$set[$days[$d] . '_appt'] = self::meta_array_value_single( $term_meta, 'hours_' . $h . '_' . $days[$d] . '_appt' );
				$set[$days[$d] . '_open'] = self::meta_array_value_single( $term_meta, 'hours_' . $h . '_' . $days[$d] . '_open' );
				$set[$days[$d] . '_close'] = self::meta_array_value_single( $term_meta, 'hours_' . $h . '_' . $days[$d] . '_close' );
			}

			$hours[] = $set;
		}
		return $hours;
	}