<?php
/**
 * Copyright © Codazon, Inc. All rights reserved.
 * See COPYING.txt for license details.
 */
?>
<?php
use Magento\Framework\App\ActionInterface;
?>
<?php
$helper = $this->helper(\Codazon\ShoppingCartPro\Helper\Data::class);
?>
<?php if ($helper->enableAjaxWishlist()) : ?>
<?php
$dataPost = [
    'action'    => $this->getUrl('ajaxpost/product_wishlist/moveallfromcart'),
    'data'      => [
        ActionInterface::PARAM_NAME_URL_ENCODED => $helper->getUrlEncoder()->encode((string)$this->getRequest()->getServer('HTTP_REFERER'))
    ]    
]
?>
<script>
require(['jquery'], function($) {
    var $destBtn = $('form.form-cart .actions .action.clear');
    if (!$destBtn.length) {
        $destBtn = $('form.form-cart .actions .action.update');
    }
    if ($destBtn.length) {
        var $wishlistBtn = $('<button type="button" class="action towishlist" data-post=\'<?= json_encode($dataPost) ?>\'><span><?= __('Move all to wish list') ?></span></button>');
        $wishlistBtn.insertBefore($destBtn);
    }
});
</script>
<?php endif ?>