<!--تنظیمات صفحه اصلی-> تنظیمات دسته بندی-->
<?php
$category_setting = array();
if (isset($_POST['woo2app-admin']) && wp_verify_nonce($_POST['woo2app-admin'], 'woo2app-admin')) {
	$category_setting = array();
	$category_setting = get_option('woo2app_category_setting');
	if(!is_array($category_setting)){
		$category_setting = array();
	}
	$category_setting['state_receive'] = 'normal' ;
	//$category_setting['product_category_page'] = $_POST['product_category_page'];
	$category_setting['product_category_page']['level_1']['selling'] = isset($_POST['product_category_page']['level_1']['selling'])  ? true : false;
	$category_setting['product_category_page']['level_1']['newer'] = isset($_POST['product_category_page']['level_1']['newer'])  ? true : false;

	$category_setting['product_category_page']['level_2']['selling'] = isset($_POST['product_category_page']['level_2']['selling'])  ? true : false;
	$category_setting['product_category_page']['level_2']['newer'] = isset($_POST['product_category_page']['level_2']['newer'])  ? true : false;

	$category_setting['product_category_page']['level_3']['selling'] = isset($_POST['product_category_page']['level_3']['selling'])  ? true : false;
	$category_setting['product_category_page']['level_3']['newer'] = isset($_POST['product_category_page']['level_3']['newer'])  ? true : false;

	$category_setting['product_category_page']['level_4']['selling'] = isset($_POST['product_category_page']['level_4']['selling'])  ? true : false;
	$category_setting['product_category_page']['level_4']['newer'] = isset($_POST['product_category_page']['level_4']['newer'])  ? true : false;
	update_option('woo2app_category_setting' , $category_setting);
}

$category_setting = get_option('woo2app_category_setting');

if(!is_array($category_setting)){
	$category_setting = array();
	$category_setting['state_receive'] = 'normal' ;
	$category_setting['product_category_page']['level_1']['selling'] = true;
	$category_setting['product_category_page']['level_1']['newer'] = true;

	$category_setting['product_category_page']['level_2']['selling'] = true;
	$category_setting['product_category_page']['level_2']['newer'] = true;

	$category_setting['product_category_page']['level_3']['selling'] = true;
	$category_setting['product_category_page']['level_3']['newer'] = true;

	$category_setting['product_category_page']['level_4']['selling'] = true;
	$category_setting['product_category_page']['level_4']['newer'] = true;
	update_option('woo2app_category_setting' , $category_setting);
}
?>
<h2>
	<?php _e('Products on the category page', 'woo2app'); ?>
</h2>
<form method="post">
	<?php wp_nonce_field('woo2app-admin', 'woo2app-admin'); ?>
    <table class="form-table ">
        <tbody>
        <!--        <tr valign="top" class="" >-->
        <!--            <th scope="row" class="titledesc" style="width: 250px;">-->
        <!--                حالت دریافت لیست دسته بندیها-->
        <!--            </th>-->
        <!--            <td class="forminp forminp-select">-->
        <!--                <select name="state_receive" class="regular-text">-->
        <!--                    <option value="normal" --><?//= selected($category_setting['state_receive'],'normal')?><!-- نرمال </option>-->
        <!--                    <option value="percat" --><?//= selected($category_setting['state_receive'],'percat')?><!-- دسته ای </option>-->
        <!--                </select>-->
        <!--                <br>-->
        <!--                حالت دسته‌ای برای فروشگاه‌هایی که دسته بندی‌های زیادی دارند پیشنهاد میشود.-->
        <!--            </td>-->
        <!--        </tr>-->
        <tr valign="top" class="" >
            <th scope="row" class="titledesc" >
				<?php _e('level 1', 'woo2app'); ?>
            </th>
            <td class="forminp forminp-select">
                <p>
                    <input type="checkbox" name="product_category_page[level_1][selling]" <?= checked($category_setting['product_category_page']['level_1']['selling'])?>>
					<?php _e('Show bestseller list', 'woo2app'); ?>
                </p>
                <p>
                    <input type="checkbox" name="product_category_page[level_1][newer]" <?= checked($category_setting['product_category_page']['level_1']['newer'])?>>
					<?php _e('Show newest list', 'woo2app'); ?>
                </p>
            </td>
        </tr>
        <tr valign="top" class="" >
            <th scope="row" class="titledesc" >
				<?php _e('level 2', 'woo2app'); ?>
            </th>
            <td class="forminp forminp-select">
                <p>
                    <input type="checkbox" name="product_category_page[level_2][selling]" <?= checked($category_setting['product_category_page']['level_2']['selling'])?>>
					<?php _e('Bestseller List', 'woo2app'); ?>
                </p>
                <p>
                    <input type="checkbox" name="product_category_page[level_2][newer]" <?= checked($category_setting['product_category_page']['level_2']['newer'])?>>
					<?php _e('Newest List', 'woo2app'); ?>
                </p>
            </td>
        </tr>
        <tr valign="top" class="" >
            <th scope="row" class="titledesc" >
				<?php _e('level 3', 'woo2app'); ?>
            </th>
            <td class="forminp forminp-select">
                <p>
                    <input type="checkbox" name="product_category_page[level_3][selling]" <?= checked($category_setting['product_category_page']['level_3']['selling'])?>>
					<?php _e('Bestseller List', 'woo2app'); ?>
                </p>
                <p>
                    <input type="checkbox" name="product_category_page[level_3][newer]" <?= checked($category_setting['product_category_page']['level_3']['newer'])?>>
					<?php _e('Newest List', 'woo2app'); ?>
                </p>
            </td>
        </tr>
        <tr valign="top" class="" >
            <th scope="row" class="titledesc" >
				<?php _e('level 4', 'woo2app'); ?>
            </th>
            <td class="forminp forminp-select">
                <p>
                    <input type="checkbox" name="product_category_page[level_4][selling]" <?= checked($category_setting['product_category_page']['level_4']['selling'])?>>
					<?php _e('Bestseller List', 'woo2app'); ?>
                </p>
                <p>
                    <input type="checkbox" name="product_category_page[level_4][newer]" <?= checked($category_setting['product_category_page']['level_4']['newer'])?>>
					<?php _e('Newest List', 'woo2app'); ?>
                </p>
            </td>
        </tr>
        </tbody>
    </table>
    <input name="submit_category_setting" class="button button-primary" value="<?php _e('Save Change', 'woo2app'); ?>"
           type="submit">
</form>
