<?php

namespace Webnestors\Wsn\Snippets;

class CheckoutAddTitleToPaymentSection extends \Webnestors\Wsn\Snippet {
    public $payment_title = "Payment Methods";

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

    public function title(): string {
        return esc_html__("Add Heading On Checkout Payment Section", "enhancements-for-woocommerce");
    }

    public function description(): string {
        return esc_html__("Show a custom title on the checkout payment section.", "enhancements-for-woocommerce");
    }

    public function meta(): array {
        return [
            [
                "label" => esc_html__("Payment Title", "enhancements-for-woocommerce"),
                "name" => "payment_title",
                "type" => "text",
            ],
        ];
    }

    public function tooltip(): ?string {
        ob_start(); ?>
        <h1><strong><?php echo esc_html($this->title()); ?></strong></h1>
        <h3>Description</h3>
        <p>The Add Heading on Checkout Payment Section module allows you to customize the WooCommerce checkout page by adding a custom heading or title above the payment section. This feature gives you the flexibility to enhance the checkout experience with a personalized message or directive, making the payment process more intuitive and aligned with your brand.</p>
        <p>By adding a heading to the payment section, you can make the checkout process clearer for customers, highlight important information, or even add a motivational phrase to encourage order completion. The heading can be anything from a simple title like "Choose Your Payment Method" to a more personalized message like "Secure Your Order Now – Select a Payment Option Below."</p>
        <h3>Settings</h3>
        <h4>Payment Title</h4>
        <p>Write the title that you like to appear on the payment section</p>
        <h3>Appearance</h3>
        <p>There is no appearence options for this module</p>
        <?php return ob_get_clean();
    }

    public function run() {
        add_action("woocommerce_review_order_before_payment", [$this, "wn_checkout_payment_options_title"]);
    }

    function wn_checkout_payment_options_title() {
        echo "<h3>" . esc_html($this->payment_title) . "</h3>";
    }
}
