PluginProbe
Tiered Pricing Table for WooCommerce / 1.0
Tiered Pricing Table for WooCommerce v1.0
7.1.7 7.1.5 7.1.4 7.1.1 6.5.0 6.4.0 6.1.0 trunk 1.0 1.1 2.0 2.0.1 2.0.2 2.1 2.1.1 2.1.2 2.2.0 2.2.1 2.2.2 2.2.3 2.3.0 2.3.1 2.3.2 2.3.3 2.3.4 All 90 releases
tier-pricing-table / src / Admin / Settings.php

Settings.php in Tiered Pricing Table for WooCommerce 1.0, at src/Admin/Settings.php

169 lines 6.5 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php namespace TierPricingTable\Admin;
2
3 use Premmerce\SDK\V2\FileManager\FileManager;
4
5 class Settings
6 {
7 const PREFIX = 'tier_pricing_table_';
8
9 /**
10 * @var FileManager
11 */
12 private $fileManager;
13
14 /**
15 * Settings constructor.
16 * @param FileManager $fileManager
17 */
18 public function __construct(FileManager $fileManager)
19 {
20 add_filter('woocommerce_general_settings', [$this, 'addPriceQuantityTableSettings']);
21 $this->fileManager = $fileManager;
22 }
23
24 public function addPriceQuantityTableSettings($settings)
25 {
26 wp_enqueue_script('quantity-table-settings-js', $this->fileManager->locateAsset('admin/settings.js'));
27
28 $settings[] = [
29 "title" => __('Tier pricing table settings', 'tier-pricing-table'),
30 "desc" => __('This controls what and where quantity table prices are displayed at product page', 'tier-pricing-table'),
31 "id" => self::PREFIX . "options",
32 "type" => "title",
33 ];
34
35 $settings[] = [
36 "title" => __('Show tier pricing table', 'tier-pricing-table'),
37 "id" => self::PREFIX . "display",
38 "type" => "checkbox",
39 "default" => "yes",
40 "desc" => __('Display a table on frontend? Prices will change even if it is off', 'tier-pricing-table'),
41 "desc_tip" => true,
42 ];
43
44 $settings[] = [
45 "title" => __('Display', 'tier-pricing-table'),
46 "id" => self::PREFIX . "display_type",
47 "type" => "select",
48 "options" => [
49 'tooltip' => __('Tooltip', 'tier-pricing-table'),
50 'table' => __('Table', 'tier-pricing-table'),
51 ],
52 "desc" => __('Type of displaying', 'tier-pricing-table'),
53 "desc_tip" => true,
54 ];
55
56 $settings[] = [
57 "title" => __('Table name', 'tier-pricing-table'),
58 "id" => self::PREFIX . "table_title",
59 "type" => "text",
60 "default" => __('', 'tier-pricing-table'),
61 "desc" => __('The name is being displayed above the table', 'tier-pricing-table'),
62 "desc_tip" => true,
63 ];
64
65 $settings[] = [
66 "title" => __('Table position', 'tier-pricing-table'),
67 "id" => self::PREFIX . "position_hook",
68 "type" => "select",
69 "options" => [
70 'woocommerce_before_add_to_cart_button' => __('Above buy button', 'tier-pricing-table'),
71 'woocommerce_after_add_to_cart_button' => __('Below buy button', 'tier-pricing-table'),
72 'woocommerce_single_product_summary' => __('Above product title', 'tier-pricing-table'),
73 'woocommerce_after_single_product_summary' => __('After product summary
74 ', 'tier-pricing-table'),
75 ],
76 "desc" => __('Where to display the table', 'tier-pricing-table'),
77 "desc_tip" => true,
78 ];
79
80 $settings[] = [
81 "title" => __('Tooltip icon color', 'tier-pricing-table'),
82 "id" => self::PREFIX . "tooltip_color",
83 "type" => "color",
84 "css" => "width:6em;",
85 "default" => "#cc99c2",
86 "desc" => __('Color of icon', 'tier-pricing-table'),
87 "desc_tip" => true,
88 ];
89
90 $settings[] = [
91 "title" => __('Tooltip icon size (px)', 'tier-pricing-table'),
92 "id" => self::PREFIX . "tooltip_size",
93 "type" => "number",
94 "default" => "15",
95 "desc" => __('Size of icon', 'tier-pricing-table'),
96 "desc_tip" => true,
97 ];
98
99 $settings[] = [
100 "title" => __('Active price background color', 'tier-pricing-table'),
101 "id" => self::PREFIX . "selected_quantity_color",
102 "type" => "color",
103 "css" => "width:6em;",
104 "default" => "#cc99c2",
105 "desc" => __('Active tier price background color', 'tier-pricing-table'),
106 "desc_tip" => true,
107 ];
108
109 $settings[] = [
110 "title" => __('Quantity text', 'tier-pricing-table'),
111 "id" => self::PREFIX . "head_quantity_text",
112 "type" => "text",
113 "default" => __('Quantity', 'tier-pricing-table'),
114 "desc" => __('Name of quantity column', 'tier-pricing-table'),
115 "desc_tip" => true,
116 ];
117
118 $settings[] = [
119 "title" => __('Price text', 'tier-pricing-table'),
120 "id" => self::PREFIX . "head_price_text",
121 "type" => "text",
122 "default" => __('Price', 'tier-pricing-table'),
123 "desc" => __('Name of price column', 'tier-pricing-table'),
124 "desc_tip" => true,
125 ];
126
127 $settings[] = [
128 "title" => __('CSS class', 'tier-pricing-table'),
129 "id" => self::PREFIX . "table_css_class",
130 "type" => "text",
131 "default" => "",
132 "desc" => __('You can add your own css styles for this class. The class will be added to the table', 'tier-pricing-table'),
133 "desc_tip" => true,
134 ];
135
136 $settings[] = [
137 "type" => "sectionend",
138 "id" => self::PREFIX . "options"
139 ];
140
141 return $settings;
142 }
143
144
145 public function getAll()
146 {
147 return [
148 'display' => $this->get('display', 'yes'),
149 'position_hook' => $this->get('position_hook', 'woocommerce_after_add_to_cart_button'),
150 'head_quantity_text' => $this->get('head_quantity_text', __('Quantity', 'tier-pricing-table')),
151 'head_price_text' => $this->get('head_price_text', __('Price', 'tier-pricing-table')),
152 'display_type' => $this->get('display_type', 'tooltip'),
153 'selected_quantity_color' => $this->get('selected_quantity_color', '#cc99c2'),
154 'table_title' => $this->get('table_title', ''),
155 'table_css_class' => $this->get('table_css_class', '#fff'),
156 'tooltip_size' => $this->get('tooltip_size', 15),
157 ];
158 }
159
160 public function get($option_name, $default = null)
161 {
162 return get_option(self::PREFIX . $option_name, $default);
163 }
164
165 public function getLink()
166 {
167 return admin_url('admin.php?page=wc-settings#'. self::PREFIX . 'display');
168 }
169 }