<?php

/**
 * Change add to cart text
 */

if (!defined('ABSPATH')) {
    exit;
}

$sapmfly_change_cart_text = get_option('sapmfly_change_cart_text', 'no');
$sapmfly_cac_text = get_option('sapmfly_cac_text');

wp_localize_script('sapmfly-admin-script', 'sapmfly_cac_ajax', [
    'nonce' => wp_create_nonce('sapmfly_cac_ajax_nonce'),
]);

?>

<div class="change-add-to-cart-wrap toggle-block-bg">

    <label class="sapmfly-switch-update">
        <div class="change-add-to-cart-header toggle-header">
            <?php echo esc_html__('Change \'Add to Cart\' text', 'minifly'); ?>
            <input type="checkbox" class="sapmfly-setting-toggle" name="sapmfly_change_cart_text" <?php checked($sapmfly_change_cart_text, 'yes'); ?> />
            <span class="sapmfly-slider"></span>
        </div>
    </label>

    <div class="sapmfly-toggle-resource-body">
        <div class="sapmfly-adjust sapmfly-open-cac-popup">
            <p><?php echo esc_html__('Change Text Here', 'minifly'); ?></p>
        </div>

        <div class="sapmfly-docs">
            <p>
                <a href="#" target="_blank">
                    <?php echo esc_html__('Docs', 'minifly'); ?>
                </a>
            </p>
        </div>
        <div class="sapmfly-tags">
            <p><?php echo esc_html__('Popular', 'minifly'); ?></p>
        </div>

    </div>

</div>


<!-- Popup code starts here -->
<div class="sapmfly-cac-popup-overlay" style="display: none;">
    <div class="sapmfly-cac-popup-modal">
        <div id="sapmfly-admin-notice-cac"></div>
        <?php if ($sapmfly_change_cart_text == 'yes') : ?>
            <h3><?php echo esc_html__('Change Add to Cart Text', 'minifly'); ?></h3>
            <span class="sapmfly-popup-to-cart-close-btn">&times;</span>
            <div class="sapmfly-cac-input-group">
                <label for="sapmfly_cac_text">
                    <?php echo esc_html__('Cart Text:', 'minifly'); ?>
                </label>
                <input type="text" id="sapmfly_cac_text" value="<?php echo esc_attr($sapmfly_cac_text); ?>" placeholder="Add to Bag" />
            </div>
            <br>
        <?php else : ?>
            <div class="sapmfly-toggle-blocked">
                <p><b><?php echo esc_html__('Please toggle ON and save changes', 'minifly'); ?></b></p>
                <span class="sapmfly-popup-to-cart-close-btn">&times;</span>
                <div class="sapmfly-cac-input-group">
                    <label for="sapmfly_cac_text">
                        <?php echo esc_html__('Cart Text:', 'minifly'); ?>
                    </label>
                    <input type="text" id="#" value="Default" placeholder="Default" disabled />
                </div>
                <br>
            </div>
        <?php endif; ?>
        <br>
        <button type="button" class="sapmfly-save-cac sapmfly-popup-btn"><?php echo esc_html__('Save', 'minifly'); ?></button>
        <button type="button" class="sapmfly-clear-cac sapmfly-popup-btn"><?php echo esc_html__('Clear', 'minifly'); ?></button>
        <button type="button" class="sapmfly-close-cac sapmfly-popup-btn"><?php echo esc_html__('Close', 'minifly'); ?></button>
    </div>
</div>