<?php

namespace Webnestors\Wsn\Snippets;

class CheckoutRenamePlaceOrder extends \Webnestors\Wsn\Snippet {
    public $placeorder_text = "Place Order";

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

    public function title(): string {
        return __("Rename Place Order Button", "enhancements-for-woocommerce");
    }

    public function description(): string {
        return __("Replace the place order button text at checkout page.", "enhancements-for-woocommerce");
    }

    public function meta(): array {
        return [
            [
                "label" => __("Place Order Button", "enhancements-for-woocommerce"),
                "description" => __("Place your text here", "enhancements-for-woocommerce"),
                "name" => "placeorder_text",
                "type" => "text",
            ],
        ];
    }

    public function tooltip(): ?string {
        ob_start(); ?>
        <h1><strong><?php echo esc_html($this->title()); ?></strong></h1>
        <h3>Description</h3>
        <p>The Rename Place Order Button module allows you to customize the text of the "Place Order" button on the WooCommerce checkout page. This feature is essential for businesses that want to tailor the checkout experience to their brand voice or provide clearer guidance to customers. By replacing the default "Place Order" text with a custom message, you can create a more engaging, informative, or action-driven checkout process.</p>
        <p>Whether you want to personalize the button to match a special promotion, clarify the next step for the customer, or simply use language that better fits your store's tone, this module offers the flexibility to achieve that.</p>
        <h3>Settings</h3>
        <h4>Place Order Button</h4>
        <p>Write the label that you want to appear</p>
        <h3>Appearance</h3>
        <p>There are no appearence options for this module</p>
        <?php return ob_get_clean();
    }

    public function run() {
        add_filter("woocommerce_order_button_text", [$this, "wn_woocommerce_custom_place_order_button"]);
    }

    function wn_woocommerce_custom_place_order_button() {
        return $this->placeorder_text;
    }
}
