<?php
/**
 * Copyright © Magento, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */

/** @var $block \Magento\Catalog\Block\Product\View */
?>
<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()) :?>
<?php
$qtyValidators = $block->getQuantityValidators();
if (isset($qtyValidators['validate-item-quantity'])) {
    if (isset($qtyValidators['validate-item-quantity']['minAllowed'])) {
        $min = $qtyValidators['validate-item-quantity']['minAllowed'];
    } else {
        $min = 1;
    }
    if (isset($qtyValidators['validate-item-quantity']['maxAllowed'])) {
        $max = $qtyValidators['validate-item-quantity']['maxAllowed'];
    } else {
        $max = 10000;
    }
} else {
    $min = 1;
    $max = 10000;
}
?>
<div class="box-tocart">
    <div class="fieldset">
        <?php if ($block->shouldRenderQuantity()) :?>
        <div class="field qty">
            <label class="label" for="qty"><span><?= $block->escapeHtml(__('Qty')) ?></span></label>
            <div class="control">
                <input type="number"
                       name="qty"
                       id="qty"
                       min="<?= $min ?>"
                       max="<?= $max ?>"
                       value="<?= $block->getProductDefaultQty() * 1 ?>"
                       title="<?= $block->escapeHtmlAttr(__('Qty')) ?>"
                       class="input-text qty input-small"
                       required
                       />
            </div>
        </div>
        <?php endif; ?>
        <div class="actions">
            <button type="submit" [text]="addtocart_text ? addtocart_text : '<?= $buttonTitle ?>'"
                    title="<?= $block->escapeHtmlAttr($buttonTitle) ?>"
                    class="btn-large btn-primary btn-tocart _btn-cart"
                    id="product-addtocart-button">
                <span><?= $block->escapeHtml($buttonTitle) ?></span>
            </button>
        </div>
    </div>
</div>
<?php endif; ?>
