<?php $_product = $block->getProduct(); ?>
<?php $buttonTitle = __('Add to Cart'); ?>
<?php if ($_product->isSaleable()): ?>
<?php 
	$helper = $this->helper("Magetop\Agency\Helper\Data"); 
	$custumerId = $helper->getCustomerId();
	$allProducts = $helper->getAssignProductCollection($_product->getId(),$custumerId);
	$advancePreviewHelper = $this->helper("Magetop\Advancepreview\Helper\Data"); 
	$customerGroup = $advancePreviewHelper->getCustomerGroup();
?>
	<?php if (count($allProducts) > 0 && $custumerId > 0): ?>
		<?php echo $this->getChildHtml('assignproduct_list') ?>
		<style>
			.product-info-main > .product-info-price > .price-box {display: none;}
		</style>
	<?php else: ?>
		<!--advance preview extension -->
		<?php echo $block->getLayout()->createBlock('Magetop\Advancepreview\Block\CustomProduct')->setTemplate('Magetop_Advancepreview::product/custom-options.phtml')->toHtml(); ?>
		<!--end -->
		<div class="box-tocart">
			<div class="fieldset">
				<?php if ($block->shouldRenderQuantity()): ?>
				<div class="field qty">
					<label class="label" for="qty"><span><?= /* @escapeNotVerified */ __('Qty') ?></span></label>
					<div class="control">
						<input type="number"
							   name="qty"
							   id="qty"
							   value="<?= /* @escapeNotVerified */ $block->getProductDefaultQty() * 1 ?>"
							   title="<?= /* @escapeNotVerified */ __('Qty') ?>"
							   class="input-text qty"
							   data-validate="<?= $block->escapeHtml(json_encode($block->getQuantityValidators())) ?>"
							   />
					</div>
				</div>
				<?php endif; ?>
				<div class="actions">
					<button type="submit"
							title="<?= /* @escapeNotVerified */ $buttonTitle ?>"
							class="action primary tocart"
							id="product-addtocart-button">
						<span><?= /* @escapeNotVerified */ $buttonTitle ?></span>
					</button>
				</div>
				<?php if($customerGroup > 1) : ?>
					<div class="actions actions-preview-request-offer">
						<button type="submit"
								title="<?php echo __('Request for offer') ?>"
								class="action primary tocart"
								id="product-preview-request-offer">
							<span><?php echo __('Request for offer') ?></span>
						</button>
					</div>
				<?php endif; ?>
			</div>
		</div>
	<?php endif; ?>
<?php endif; ?>
<?php if ($block->isRedirectToCartEnabled()) : ?>
<script type="text/x-magento-init">
    {
        "#product_addtocart_form": {
            "Magento_Catalog/product/view/validation": {
                "radioCheckboxClosest": ".nested"
            }
        }
    }
</script>
<?php else : ?>
<script type="text/x-magento-init">
    {
        "#product_addtocart_form": {
            "Magento_Catalog/js/validate-product": {}
        }
    }
</script>
<?php endif; ?>
