<?php

if ( !defined( 'ABSPATH' ) ) {
    exit;
}

if ( !class_exists( 'Reon' ) ) {
    return;
}

if ( !class_exists( 'Pricely_Admin_Cart_Discounts_Settings' ) ) {

    class Pricely_Admin_Cart_Discounts_Settings {

        public function __construct() {

            add_filter( 'pricely_admin_get-settings-section-panels', array( $this, 'get_panel' ), 20 );
        }

        public function get_panel( $in_fields ) {

            $in_fields[] = array(
                'id' => 'any_id',
                'type' => 'panel',
                'last' => true,
                'white_panel' => false,
                'panel_size' => 'smaller',
                'width' => '100%',
                'field_css_class' => array( 'pricely_setting_panel' ),
                'css_class' => array( 'rn-round-small' ),
                'merge_fields' => false,
                'fields' => $this->get_fields( array() ),
            );


            return $in_fields;
        }

        private function get_fields( $in_fields ) {

            $in_fields[] = array(
                'id' => 'any_id',
                'type' => 'paneltitle',
                'full_width' => true,
                'center_head' => true,
                'title' => esc_html__( 'Cart Discounts', 'pricely-dynamic-pricing-cart-discounts' ),
                'desc' => esc_html__( 'Use these settings to configure cart discounts', 'pricely-dynamic-pricing-cart-discounts' ),
            );

            $in_fields[] = array(
                'id' => 'cart_discount_settings',
                'type' => 'columns-field',
                'columns' => 1,
                'merge_fields' => true,
                'fields' => array(
                    array(
                        'id' => 'replace_coupon_labels',
                        'type' => 'select2',
                        'column_size' => 1,
                        'column_title' => esc_html__( 'Replace Coupon Labels', 'pricely-dynamic-pricing-cart-discounts' ),
                        'tooltip' => esc_html__( 'Select whether to replace coupon labels with discount titles on the cart and checkout pages.', 'pricely-dynamic-pricing-cart-discounts' ),
                        'default' => array( 'yes' ),
                        'options' => array(
                            'yes' => esc_html__( 'Yes, Replace coupon labels with discount titles', 'pricely-dynamic-pricing-cart-discounts' ),
                        ),
                        'width' => '100%',
                    ),
                ),
            );

            return $in_fields;
        }

    }

    new Pricely_Admin_Cart_Discounts_Settings;
}