<?php

namespace Webnestors\Wsn\Snippets;

class ArchivesDisplayStockStatus extends \Webnestors\Wsn\Snippet {
    public $instock_text = "Available";

    public $onbackorder_text = "After Order";

    public $outofstock_text = "Not now";

    public $badge_position = "woocommerce_before_shop_loop";

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

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

    public function title() : string {
        return esc_html__( "Display Stock Status", "enhancements-for-woocommerce" );
    }

    public function description() : string {
        return esc_html__( "Show the stock status with custom text for each status. The css class `wn-product-stock` is available on the text element.", "enhancements-for-woocommerce" );
    }

    public function meta() : array {
        return [
            [
                "label" => esc_html__( "In stock Text", "enhancements-for-woocommerce" ),
                "name"  => "instock_text",
                "type"  => "text",
            ],
            [
                "label" => esc_html__( "On Backorder Text", "enhancements-for-woocommerce" ),
                "name"  => "onbackorder_text",
                "type"  => "text",
            ],
            [
                "label" => esc_html__( "Out of Stock Text", "enhancements-for-woocommerce" ),
                "name"  => "outofstock_text",
                "type"  => "text",
            ],
            [
                "label"         => esc_html__( "Badge Position", "enhancements-for-woocommerce" ),
                "description"   => esc_html__( "Choose where to place the badge on the product.", "enhancements-for-woocommerce" ),
                "name"          => "badge_position",
                "type"          => "select",
                "options"       => [
                    "woocommerce_before_shop_loop_item_title",
                    "woocommerce_shop_loop_item_title",
                    "woocommerce_after_shop_loop_item_title",
                    "woocommerce_after_shop_loop_item"
                ],
                "option_labels" => [
                    "Before Product Image",
                    "Before Product Title",
                    "After Product Title",
                    "Before Add to Cart Button"
                ],
            ]
        ];
    }

    public function tooltip() : ?string {
        ob_start();
        ?>
        <h1><strong><?php 
        echo esc_html( $this->title() );
        ?></strong></h1>
        <h3>Description</h3>
        <p>The Display Stock Status module enables you to show a custom stock status message on WooCommerce archive and product pages, tailored to each inventory status (e.g., "In Stock," "Low Stock - Order Soon," "Out of Stock"). This feature allows you to provide clear and customized notifications regarding product availability, giving customers a quick view of stock levels and helping manage expectations for popular or limited items.</p>
        <p>Ideal for stores that want to maintain transparency around stock levels, this module is particularly useful for products with fluctuating inventory or items that require urgency messaging to encourage purchases.</p>
        <h3>Settings</h3>
        <p>Place the desired text on each corresponding field</p>
        <h3>Appearance</h3>
        <p>You can use the "wn-product-stock" class to customize the appearence</p>
        <?php 
        return ob_get_clean();
    }

    public function run() {
    }

    function webnestors_display_attributes() {
    }

    function webnestors_attributes() {
    }

}
