<?php

namespace Webnestors\Wsn\Snippets;

class CartFreeShippingNotification extends \Webnestors\Wsn\Snippet {
    public $min_amount = 100;

    public $notice = "";

    public $btn_text = "";

    public $notification_position = "";

    public function is_pro() : bool {
        return true;
    }

    public function tab() : string {
        return "cart";
    }

    public function title() : string {
        return esc_html__( "Amount Left for Free Shipping", "enhancements-for-woocommerce" );
    }

    public function description() : string {
        return esc_html__( "A Notification that displays the amount left for free shipping, according to your WooCommerce settings of free shipping.", "enhancements-for-woocommerce" );
    }

    public function meta() : array {
        return [
            [
                "label"       => esc_html__( "Amount Threshold", "enhancements-for-woocommerce" ),
                "description" => esc_html__( "This is the amount of your free shipping threshold. Change according to your free shipping settings", "enhancements-for-woocommerce" ),
                "name"        => "min_amount",
                "type"        => "text",
            ],
            [
                "label"       => esc_html__( "Notification Text", "enhancements-for-woocommerce" ),
                "description" => esc_html__( "Use the placeholder %%amount_left%% to reference the remaining amount. For example: (Only %%amount_left%% left for free shipping)", "enhancements-for-woocommerce" ),
                "name"        => "notice",
                "type"        => "text",
            ],
            [
                "label"       => esc_html__( "Button", "enhancements-for-woocommerce" ),
                "description" => esc_html__( "Example (Continue Shopping)", "enhancements-for-woocommerce" ),
                "name"        => "btn_text",
                "type"        => "text",
            ],
            [
                "label"         => esc_html__( "Notification Position", "enhancements-for-woocommerce" ),
                "description"   => esc_html__( "Choose where to place the notification on the cart page. If the hook is not working select to use the shortcode and save. The shortcode is [wn_freeshippingleft]", "enhancements-for-woocommerce" ),
                "name"          => "notification_position",
                "type"          => "select",
                "options"       => [
                    "woocommerce_before_cart_table",
                    "woocommerce_before_cart_contents",
                    "woocommerce_after_cart_contents",
                    "woocommerce_after_cart_table",
                    "woocommerce_cart_totals_before_shipping",
                    "woocommerce_before_shipping_calculator",
                    "woocommerce_after_shipping_calculator",
                    "woocommerce_cart_totals_after_shipping",
                    "woocommerce_cart_totals_before_order_total",
                    "woocommerce_cart_totals_after_order_total",
                    "woocommerce_proceed_to_checkout",
                    "woocommerce_after_cart_totals",
                    ""
                ],
                "option_labels" => [
                    "Before cart table",
                    "Before cart contents",
                    "After cart contents",
                    "After cart table",
                    "Before totals shipping",
                    "Before shipping calculator",
                    "After shipping calculator",
                    "After totals shipping",
                    "Before order total",
                    "After order total",
                    "Before checkout button",
                    "After cart totals",
                    "Use Shortcode"
                ],
            ]
        ];
    }

    public function tooltip() : ?string {
        ob_start();
        ?>
        <h1><strong><?php 
        echo esc_html( $this->title() );
        ?></strong></h1>
        <h3>Description</h3>
        <p>The Amount Left for Free Shipping module adds a dynamic notification to your WooCommerce store, letting customers know how much more they need to spend to qualify for free shipping. This feature calculates the current cart total and automatically displays the remaining amount required for free shipping, based on the WooCommerce free shipping settings you’ve configured.</p>
        <p>This is a powerful tool for encouraging customers to increase their order value. By informing customers that they are close to receiving free shipping, you incentivize them to add more products to their cart, improving both the shopping experience and your store’s average order value.</p>
        <h3>Settings</h3>
        <h4>Amount Threshold</h4>
        <p>This is the amount of your free shipping threshold. Change according to your free shipping settings.</p>
        <h4>Notification Text</h4>
        <p>Use the placeholder %%amount_left%% to reference the remaining amount. For example: (Only %%amount_left%% left for free shipping)</p>
        <h4>Button</h4>
        <p>Write the text for the button label. Example (Continue Shopping).</p>
        <h4>Notification Position</h4>
        <p>The position you want to place the notification on the cart.</p>
        <p>Note: The position might not always work if your theme does not support the default WooCommerce hooks, try to change the position and check if the notification appears</p>
        <p>Tip: If the position does not work you can use the shotcode [wn_freeshippingleft] wherever you like</p>
        <h3>Appearance</h3>
        <p>You can use custom css to customize the Appearance of the module, use the class ".woocommerce-message".</p>
        <?php 
        return ob_get_clean();
    }

    public function run() {
    }

    function cart_page_notice() {
    }

    function freesphippingleft() {
    }

}
