<?php
/**
 +===========================================================================+
 |    ____         __            ____ _               _               _      |
 |   / ___|  __ _ / _| ___ _ __ / ___| |__   ___  ___| | _____  _   _| |_    |
 |   \___ \ / _` | |_ / _ \ '__| |   | '_ \ / _ \/ __| |/ / _ \| | | | __|   |
 |    ___) | (_| |  _|  __/ |  | |___| | | |  __/ (__|   < (_) | |_| | |_    |
 |   |____/ \__,_|_|  \___|_|   \____|_| |_|\___|\___|_|\_\___/ \__,_|\__|   |
 |                                                                           |
 | (c) NinTechNet Limited ~ https://nintechnet.com/safercheckout/            |
 +===========================================================================+ 2024-05-10
*/

if (! defined('ABSPATH') ) {
	die('Forbidden');
}

// ===========================================================================
// Display the "Order" page.

wp_nonce_field('safercheckout-nonce', 'safercheckout-nonce', 0);
?>
<input type="hidden" id="safercheckout-settings" name="safercheckout-settings" value="settings-order" />

<h2><?php esc_html_e('Order', 'safercheckout-lite') ?></h2>
<table class="form-table sco-border-grey">
<tbody>
	<?php
	// Purchase price threshold
	if (! isset( $this->sc_options['order_price_threshold'] ) ||
		! preg_match('/^\d+:\d+$/D', $this->sc_options['order_price_threshold'] ) ) {

		$this->sc_options['order_price_threshold'] = $this->sc_default['order_price_threshold'];
	}
	$price = explode(':', $this->sc_options['order_price_threshold'] );

	// Order quantity threshold
	if (! isset( $this->sc_options['order_quantity_threshold'] ) ||
		! preg_match('/^\d+:\d+$/D', $this->sc_options['order_quantity_threshold'] ) ) {

		$this->sc_options['order_quantity_threshold'] = $this->sc_default['order_quantity_threshold'];
	}
	$quantity = explode(':', $this->sc_options['order_quantity_threshold'] );
	?>
	<tr valign="top">
		<th scope="row">
			<label>
				<?php esc_html_e('Order value limits', 'safercheckout-lite') ?> <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php esc_attr_e('This is the minimum and maximum amount that the shoppers need to spend to checkout successfully, otherwise the order will be rejected.', 'safercheckout-lite') ?>"></span>
			</label>
		</th>
		<td>
			<p><label><?php esc_html_e('Minimum order value:', 'safercheckout-lite');	?>
			&nbsp;<input type="number" name="safercheckout_order_price_threshold_1" id="safercheckout_order_price_threshold_1" value="<?php echo esc_attr( $price[0] ) ?>" style="width:90px;vertical-align: baseline" min="0" step="1" />
			</label></p>
			<p class="description"><?php esc_html_e('Set this policy to 0 if you want to disable it.', 'safercheckout-lite') ?></p>
			<br />
			<p><label><?php esc_html_e('Maximum order value:', 'safercheckout-lite');	?>
			&nbsp;<input type="number" name="safercheckout_order_price_threshold_2" id="safercheckout_order_price_threshold_2" value="<?php echo esc_attr( $price[1] ) ?>" style="width:90px;vertical-align: baseline" min="0" step="1" /></label></p>
			<p class="description"><?php esc_html_e('Set this policy to 0 if you want to disable it.', 'safercheckout-lite') ?></p>
		</td>
	</tr>

	<tr valign="top">
		<th scope="row">
			<label>
				<?php esc_html_e('Order quantity limits', 'safercheckout-lite') ?> <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php esc_attr_e('This is the minimum and maximum purchase quantity required for a product across all variations in a single order. If the quantity is outside that range, the order will be rejected.', 'safercheckout-lite') ?>"></span>
			</label>
		</th>
		<td>
			<p><label><?php esc_html_e('Minimum order quantity:', 'safercheckout-lite');	?>
			&nbsp;<input type="number" name="safercheckout_order_quantity_threshold_1" id="safercheckout_order_quantity_threshold_1" value="<?php echo esc_attr( $quantity[0] ) ?>" style="width:90px;vertical-align: baseline" min="0" step="1" />
			</label></p>
			<p class="description"><?php esc_html_e('Set this policy to 0 if you want to disable it.', 'safercheckout-lite') ?></p>
			<br />
			<p><label><?php esc_html_e('Maximum order quantity:', 'safercheckout-lite');	?>
			&nbsp;<input type="number" name="safercheckout_order_quantity_threshold_2" id="safercheckout_order_quantity_threshold_2" value="<?php echo esc_attr( $quantity[1] ) ?>" style="width:90px;vertical-align: baseline" min="0" step="1" />
			</label></p>
			<p class="description"><?php esc_html_e('Set this policy to 0 if you want to disable it.', 'safercheckout-lite') ?></p>
		</td>
	</tr>

	<tr valign="top">
		<th scope="row">
			<label>
				<?php esc_html_e('Rate limiting', 'safercheckout-lite') ?> <sup class="sco-pro-only">Pro</sup> <span class="woocommerce-help-tip" tabindex="0" aria-label="<?php printf(
					/* Translators: 1 = 'Empty cache now!', 2 = 'Advanced Settings' */
					esc_attr__('This option allows you to block velocity attacks, also known as carding attacks. Any user reaching the defined threshold will be banned from placing an order for a certain amount of time. Velocity checks can apply to the user IP address, email address, phone number, customer session ID and/or first & last name. Note: Users temporarily banned by the Rate Limiting option can be unblocked immediately by clicking the "%1$s" button in the "%2$s" section.', 'safercheckout-lite'),
					esc_attr__('Empty cache now!', 'safercheckout-lite'),
					esc_attr__('Advanced Settings', 'safercheckout-lite')
				); ?>"></span>
			</label>
		</th>
		<td>
			<p><label><input type="checkbox" disabled /> <?php esc_html_e('Enable rate limiting.', 'safercheckout-lite') ?></label></p>

			<br />

			<p><label>
				<?php
				printf(
					/* Translators: Block for [number] [second|minute|hour] any customer with more than [number] [attempts|failed attempts] to place an order within a [number]-[second|minute|hour] interval. */
					esc_html__('Block for %1$s %2$s any customer with more than %3$s %4$s to place an order within a %5$s-%6$s interval.', 'safercheckout-lite'),
					'<input type="number" min="0" style="width:90px;" disabled value="30" />',
					'<select style="width:auto;vertical-align:middle" disabled /><option selected>'. esc_html__('second(s)', 'safercheckout-lite') .'</option><option>'. esc_html__('minute(s)', 'safercheckout-lite') .'</option><option>'. esc_html__('hour(s)', 'safercheckout-lite') .'</option></select>',
					'<input type="number" min="0" style="width:90px;" disabled value="5" />',
					'<select style="width:auto;vertical-align:middle" disabled><option>'. esc_html__('attempts', 'safercheckout-lite') .'</option><option selected>'. esc_html__('failed attempts', 'safercheckout-lite') .'</option></select>',
					'<input type="number" min="0" style="width:90px" disabled value="5" />',
					'<select style="width:auto;vertical-align:middle" disabled /><option selected>'. esc_html__('second', 'safercheckout-lite') .'</option><option>'. esc_html__('minute', 'safercheckout-lite') .'</option><option>'. esc_html__('hour', 'safercheckout-lite') .'</option></select>'
				);
				?>
			</label></p>
		</td>
	</tr>
	<tr valign="top">
		<th scope="row">&nbsp;</th>
		<td>
			<label id="geo-apply"><?php esc_html_e('Apply velocity checks to:', 'safercheckout-lite') ?></label>
			<p><label><input type="checkbox" checked disabled /> <?php esc_html_e('Customer\'s IP address.', 'safercheckout-lite') ?></label></p>
			<p><label><input type="checkbox" checked disabled /> <?php esc_html_e('Customer\'s phone number.', 'safercheckout-lite') ?></label></p>
			<p><label><input type="checkbox" checked disabled /> <?php esc_html_e('Customer\'s email address.', 'safercheckout-lite') ?></label></p>
			<p><label><input type="checkbox" checked disabled /> <?php esc_html_e('Customer\'s session ID.', 'safercheckout-lite') ?></label></p>
			<p><label><input type="checkbox" checked disabled /> <?php esc_html_e('Customer\'s first and last name.', 'safercheckout-lite') ?></label></p>
			<p class="description"><?php esc_html_e('Each velocity check applies to both authenticated and unauthenticated customers.', 'safercheckout-lite') ?></p>
		</td>
	</tr>
</tbody>
</table>
<?php
// ===========================================================================
// EOF
