# tier-pricing-table/2.1.1/assets/admin/settings.js

Tiered Pricing Table for WooCommerce, version 2.1.1. 75 lines.

- Page: https://pluginprobe.com/plugins/tier-pricing-table/2.1.1/code/assets/admin/settings.js
- Raw: https://pluginprobe.com/plugins/tier-pricing-table/2.1.1/raw/assets/admin/settings.js
- Modified: 2019-03-26T15:40:10+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/tier-pricing-table/2.1.1/code/assets/admin/settings.js#L10-L20`.

```javascript
jQuery(document).ready(function ($) {
    var TieredPricingSettings = function () {
        this.init = function () {
            this.prefix = 'tier_pricing_table_';
            this.$displayType = $('[name=' + this.prefix + 'display_type]');
            this.$displayAtCatalog = $('[name=' + this.prefix + 'tiered_price_at_catalog]');
            this.$showDiscountColumn = $('[name=' + this.prefix + 'show_discount_column]');

            this.$displayType.on('change', (function () {

                if (this.$displayType.val() === 'tooltip') {
                    this.hideRow(this.getRow('position_hook'));
                    this.hideRow(this.getRow('table_title'));
                    this.showRow(this.getRow('tooltip_color'));
                    this.showRow(this.getRow('tooltip_size'));
                    this.showRow(this.getRow('tooltip_border'));
                } else {
                    this.showRow(this.getRow('position_hook'));
                    this.showRow(this.getRow('table_title'));
                    this.hideRow(this.getRow('tooltip_size'));
                    this.hideRow(this.getRow('tooltip_color'));
                    this.hideRow(this.getRow('tooltip_border'));
                }

            }).bind(this));

            this.getRow('tiered_price_at_catalog_type').on('change', (function (e) {
                if ($(e.target).val() === 'lowest') {
                    this.showRow(this.getRow('lowest_prefix'));
                } else {
                    this.hideRow(this.getRow('lowest_prefix'));
                }
            }).bind(this));

            this.$displayAtCatalog.on('change', (function () {
                if (this.$displayAtCatalog.attr('checked')) {
                    this.showRow(this.getRow('tiered_price_at_catalog_type'));
                    this.showRow(this.getRow('tiered_price_at_catalog_for_variable'));
                } else {
                    this.hideRow(this.getRow('tiered_price_at_catalog_type'));
                    this.hideRow(this.getRow('tiered_price_at_catalog_for_variable'));
                }
            }).bind(this));

            this.$showDiscountColumn.on('change', (function () {
                if (this.$showDiscountColumn.attr('checked')) {
                    this.showRow(this.getRow('head_discount_text'));
                } else {
                    this.hideRow(this.getRow('head_discount_text'));
                }
            }).bind(this));

            this.$displayType.trigger('change');
            this.$displayAtCatalog.trigger('change');
            this.$showDiscountColumn.trigger('change');
            this.getRow('tiered_price_at_catalog_type').trigger('change');
        };

        this.showRow = function (el) {
            el.closest('tr').show(100);
        };

        this.hideRow = function (el) {
            el.closest('tr').hide(100);
        };

        this.getRow = function (settingsName) {
            return $('[name=' + this.prefix + settingsName + ']');
        }
    };

    var tieredPricingSettings = new TieredPricingSettings();

    tieredPricingSettings.init();
});
```
