<?php
/*
 * @category: Magepow
 * @copyright: Copyright (c) 2014 Magepow (http://www.magepow.com/)
 * @licence: http://www.magepow.com/license-agreement
 * @author: MichaelHa
 * @create date: 2019-06-14 17:19:50
 * @LastEditors: MichaelHa
 * @LastEditTime: 2019-06-29 12:47:17
 */
?>
<?php
$helper = $block->getAjaxHelper();
$addUrl = $block->getUrl('ajaxcart');
$quickview = 'false';
$isProductView = 'false';

if ($block->getRequest()->getModuleName() == 'ajaxcart') {
    $quickview = 'true';
    $isProductView = 'true';
}

if ($block->getRequest()->getFullActionName() == 'catalog_product_view') {
    $isProductView = 'true';
}

$isEnable = $helper->isEnabled();

if ($isProductView == 'true' && !$helper->isEnabledProductView()) {
    $isEnable = false;
}

if ($block->getRequest()->getFullActionName() == 'checkout_cart_index'
    || $block->getRequest()->getFullActionName() == 'wishlist_index_index'
    || $block->getRequest()->getFullActionName() == 'checkout_cart_configure') {
    $isEnable = false;
}
?>

<?php if ($isEnable) :?>
    <div id="magepow_ajaxcart_popup"></div>

    <script type="text/x-magento-init">
        {
            "body": {
            "magepowAjaxcart": {
            "addUrl": "<?php echo $block->escapeUrl($addUrl); ?>",
            "quickview": <?php echo $block->escapeJsQuote($quickview); ?>,
            "isProductView": <?php echo $block->escapeJsQuote($isProductView); ?>,
            "quickViewUrl": "<?php echo $block->escapeUrl($block->getUrl('alothemes/product/view/')); ?>",
            "addToCartSelector": "<?php echo $block->escapeJsQuote($helper->getAddToCartSelector()); ?>"
        }
    }
}
</script>
<?php endif; ?>