<?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);
?>
	<?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: ?>
		<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>
			</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; ?>
