WC_Report_Sales_By_Category::category_widget()publicWC 1.0

Output category widget.

Метод класса: WC_Report_Sales_By_Category{}

Хуков нет.

Возвращает

null. Ничего (null).

Использование

$WC_Report_Sales_By_Category = new WC_Report_Sales_By_Category();
$WC_Report_Sales_By_Category->category_widget();

Код WC_Report_Sales_By_Category::category_widget() WC 8.7.0

<?php
public function category_widget() {

	$categories = get_terms( 'product_cat', array( 'orderby' => 'name' ) );
	?>
	<form method="GET">
		<div>
			<select multiple="multiple" data-placeholder="<?php esc_attr_e( 'Select categories&hellip;', 'woocommerce' ); ?>" class="wc-enhanced-select" id="show_categories" name="show_categories[]" style="width: 205px;">
				<?php
					$r                 = array();
					$r['pad_counts']   = 1;
					$r['hierarchical'] = 1;
					$r['hide_empty']   = 1;
					$r['value']        = 'id';
					$r['selected']     = $this->show_categories;

					include_once WC()->plugin_path() . '/includes/walkers/class-wc-product-cat-dropdown-walker.php';

					echo wc_walk_category_dropdown_tree( $categories, 0, $r ); // @codingStandardsIgnoreLine
				?>
			</select>
			<?php // @codingStandardsIgnoreStart ?>
			<a href="#" class="select_none"><?php esc_html_e( 'None', 'woocommerce' ); ?></a>
			<a href="#" class="select_all"><?php esc_html_e( 'All', 'woocommerce' ); ?></a>
			<button type="submit" class="submit button" value="<?php esc_attr_e( 'Show', 'woocommerce' ); ?>"><?php esc_html_e( 'Show', 'woocommerce' ); ?></button>
			<input type="hidden" name="range" value="<?php echo ( ! empty( $_GET['range'] ) ) ? esc_attr( wp_unslash( $_GET['range'] ) ) : ''; ?>" />
			<input type="hidden" name="start_date" value="<?php echo ( ! empty( $_GET['start_date'] ) ) ? esc_attr( wp_unslash( $_GET['start_date'] ) ) : ''; ?>" />
			<input type="hidden" name="end_date" value="<?php echo ( ! empty( $_GET['end_date'] ) ) ? esc_attr( wp_unslash( $_GET['end_date'] ) ) : ''; ?>" />
			<input type="hidden" name="page" value="<?php echo ( ! empty( $_GET['page'] ) ) ? esc_attr( wp_unslash( $_GET['page'] ) ) : ''; ?>" />
			<input type="hidden" name="tab" value="<?php echo ( ! empty( $_GET['tab'] ) ) ? esc_attr( wp_unslash( $_GET['tab'] ) ) : ''; ?>" />
			<input type="hidden" name="report" value="<?php echo ( ! empty( $_GET['report'] ) ) ? esc_attr( wp_unslash( $_GET['report'] ) ) : ''; ?>" />
			<?php // @codingStandardsIgnoreEnd ?>
		</div>
		<script type="text/javascript">
			jQuery(function(){
				// Select all/None
				jQuery( '.chart-widget' ).on( 'click', '.select_all', function() {
					jQuery(this).closest( 'div' ).find( 'select option' ).attr( 'selected', 'selected' );
					jQuery(this).closest( 'div' ).find('select').trigger( 'change' );
					return false;
				});

				jQuery( '.chart-widget').on( 'click', '.select_none', function() {
					jQuery(this).closest( 'div' ).find( 'select option' ).prop( 'selected', false );
					jQuery(this).closest( 'div' ).find('select').trigger( 'change' );
					return false;
				});
			});
		</script>
	</form>
	<?php
}