<?php

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

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

if ( !class_exists( 'Pricely_Admin_Cart_Discounts_Panel_Coupon' ) ) {

    class Pricely_Admin_Cart_Discounts_Panel_Coupon {

        public function __construct() {

            add_filter( 'pricely_admin_cart-discounts_get-panels', array( $this, 'get_panel' ), 30 );
        }

        public function get_panel( $in_fields ) {


            $in_fields[] = array(
                'id' => 'coupon',
                'type' => 'panel',
                'full_width' => true,
                'center_head' => true,
                'white_panel' => true,
                'panel_size' => 'smaller',
                'width' => '100%',
                'merge_fields' => true,
                'last' => true,
                'field_css_class' => array( 'pricely_lone_panel', 'pricely_after_option_list' ),
                'css_class' => array( 'rn-round-small' ),
                'fields' => $this->get_panel_fields( array() ),
            );

            return $in_fields;
        }

        public function get_panel_fields( $in_fields ) {

            $in_fields[] = array(
                'id' => 'any_id1',
                'type' => 'columns-field',
                'columns' => 3,
                'merge_fields' => false,
                'fields' => array(
                    array(
                        'id' => 'auto_add',
                        'type' => 'select2',
                        'column_size' => 1,
                        'column_title' => esc_html__( 'Automatically Add Coupon', 'pricely-dynamic-pricing-cart-discounts' ),
                        'tooltip' => esc_html__( 'Determines whether the coupon should be added to cart automatically', 'pricely-dynamic-pricing-cart-discounts' ),
                        'default' => 'yes',
                        'options' => array(
                            'yes' => esc_html__( 'Yes, Coupon should be added to cart automatically', 'pricely-dynamic-pricing-cart-discounts' ),
                        ),
                        'width' => '100%',
                    ),
                    array(
                        'id' => 'individual_use',
                        'type' => 'select2',
                        'column_size' => 1,
                        'column_title' => esc_html__( 'Individual Use Only', 'pricely-dynamic-pricing-cart-discounts' ),
                        'tooltip' => esc_html__( 'Specify whether the coupon can be used in combination with other coupons', 'pricely-dynamic-pricing-cart-discounts' ),
                        'default' => 'yes',
                        'options' => array(
                            'yes' => esc_html__( 'Yes, Can be used in combination with other coupons', 'pricely-dynamic-pricing-cart-discounts' ),
                        ),
                        'width' => '100%',
                    ),
                    array(
                        'id' => 'allow_removal',
                        'type' => 'select2',
                        'column_size' => 1,
                        'column_title' => esc_html__( 'Allow Coupon Removal', 'pricely-dynamic-pricing-cart-discounts' ),
                        'tooltip' => esc_html__( 'Specify whether customers are allowed to remove the coupon from the cart', 'pricely-dynamic-pricing-cart-discounts' ),
                        'default' => 'no',
                        'options' => array(
                            'no' => esc_html__( 'No, Customer cannot remove the coupon', 'pricely-dynamic-pricing-cart-discounts' ),
                        ),
                        'width' => '100%',
                    ),
                ),
            );

            return $in_fields;
        }

    }

    new Pricely_Admin_Cart_Discounts_Panel_Coupon();
}
