<?php

namespace Webnestors\Wsn\Snippets;

class GeneralChangeAddToCartButtonText extends \Webnestors\Wsn\Snippet {
    public $cart_button_text = "Buy Now";

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

    public function title(): string {
        return __("Change Add to Cart Button Text", "enhancements-for-woocommerce");
    }

    public function description(): string {
        return __(
            "Change the add to cart button label, this will change the button text in all archive and single product pages",
            "enhancements-for-woocommerce"
        );
    }

    public function meta(): array {
        return [
            [
                "label" => __("Add to cart Text", "enhancements-for-woocommerce"),
                "description" => __("Place your text here to be shown on the Add to Cart Button", "enhancements-for-woocommerce"),
                "name" => "cart_button_text",
                "type" => "text",
            ],
        ];
    }

    public function tooltip(): ?string {
        ob_start(); ?>
        <h1><strong><?php echo esc_html($this->title()); ?></strong></h1>
        <h3>Description</h3>
        <p>The Change Add to Cart Button Text module provides a simple yet powerful way to customize the call-to-action on your WooCommerce store. This feature allows you to modify the text of the "Add to Cart" button across your entire store, including both archive (shop or category) pages and individual product pages. It’s a great tool for store owners looking to fine-tune the shopping experience and better align the user interface with their brand’s messaging, promotional goals, or specific business needs.</p>
        <p>By default, WooCommerce uses the standard "Add to Cart" label on product pages. However, this might not always suit your store’s specific requirements. For instance, if you’re offering a service rather than a physical product, you might prefer the button to say "Book Now" or "Request a Quote." If you’re running a sale or promotion, you might want to use more engaging phrases like "Buy Now" or "Grab Yours Today!" This module allows for such customization with ease, giving you control over the language and tone you want to convey to your customers.</p>
        <h3>Settings</h3>
        <h4>Add to cart Text</h4>
        <p>Write a text that will replace the "Add to Cart" Button Label</p>
        <h3>Appearance</h3>
        <p>There are no customization options for this module, the button appearance depends on your theme. You can also use custom css to modify the look of the button.</p>
        <?php return ob_get_clean();
    }

    public function run() {
        add_filter("woocommerce_product_single_add_to_cart_text", [$this, "wn_add_to_cart_button_text"]);
        add_filter("woocommerce_product_add_to_cart_text", [$this, "wn_add_to_cart_button_text"]);
    }

    function wn_add_to_cart_button_text() {
        return $this->cart_button_text;
    }
}
