PluginProbe
Tiered Pricing Table for WooCommerce / 2.0.2
Tiered Pricing Table for WooCommerce v2.0.2
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 2.0.2, at src/Admin/Settings.php

168 lines 6.3 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" => __('Tiered price 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 tiered price 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" => '',
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', 'tier-pricing-table'),
74 ],
75 "desc" => __('Where to display the table', 'tier-pricing-table'),
76 "desc_tip" => true,
77 ];
78
79 $settings[] = [
80 "title" => __('Tooltip icon color', 'tier-pricing-table'),
81 "id" => self::PREFIX . "tooltip_color",
82 "type" => "color",
83 "css" => "width:6em;",
84 "default" => "#cc99c2",
85 "desc" => __('Color of icon', 'tier-pricing-table'),
86 "desc_tip" => true,
87 ];
88
89 $settings[] = [
90 "title" => __('Tooltip icon size (px)', 'tier-pricing-table'),
91 "id" => self::PREFIX . "tooltip_size",
92 "type" => "number",
93 "default" => "15",
94 "desc" => __('Size of icon', 'tier-pricing-table'),
95 "desc_tip" => true,
96 ];
97
98 $settings[] = [
99 "title" => __('Active price background color', 'tier-pricing-table'),
100 "id" => self::PREFIX . "selected_quantity_color",
101 "type" => "color",
102 "css" => "width:6em;",
103 "default" => "#cc99c2",
104 "desc" => __('Active tired price background color', 'tier-pricing-table'),
105 "desc_tip" => true,
106 ];
107
108 $settings[] = [
109 "title" => __('Quantity text', 'tier-pricing-table'),
110 "id" => self::PREFIX . "head_quantity_text",
111 "type" => "text",
112 "default" => __('Quantity', 'tier-pricing-table'),
113 "desc" => __('Name of quantity column', 'tier-pricing-table'),
114 "desc_tip" => true,
115 ];
116
117 $settings[] = [
118 "title" => __('Price text', 'tier-pricing-table'),
119 "id" => self::PREFIX . "head_price_text",
120 "type" => "text",
121 "default" => __('Price', 'tier-pricing-table'),
122 "desc" => __('Name of price column', 'tier-pricing-table'),
123 "desc_tip" => true,
124 ];
125
126 $settings[] = [
127 "title" => __('CSS class', 'tier-pricing-table'),
128 "id" => self::PREFIX . "table_css_class",
129 "type" => "text",
130 "default" => "",
131 "desc" => __('You can add your own css styles for this class. The class will be added to the table', 'tier-pricing-table'),
132 "desc_tip" => true,
133 ];
134
135 $settings[] = [
136 "type" => "sectionend",
137 "id" => self::PREFIX . "options"
138 ];
139
140 return $settings;
141 }
142
143
144 public function getAll()
145 {
146 return [
147 'display' => $this->get('display', 'yes'),
148 'position_hook' => $this->get('position_hook', 'woocommerce_after_add_to_cart_button'),
149 'head_quantity_text' => $this->get('head_quantity_text', __('Quantity', 'tier-pricing-table')),
150 'head_price_text' => $this->get('head_price_text', __('Price', 'tier-pricing-table')),
151 'display_type' => $this->get('display_type', 'tooltip'),
152 'selected_quantity_color' => $this->get('selected_quantity_color', '#cc99c2'),
153 'table_title' => $this->get('table_title', ''),
154 'table_css_class' => $this->get('table_css_class', '#fff'),
155 'tooltip_size' => $this->get('tooltip_size', 15),
156 ];
157 }
158
159 public function get($option_name, $default = null)
160 {
161 return get_option(self::PREFIX . $option_name, $default);
162 }
163
164 public function getLink()
165 {
166 return admin_url('admin.php?page=wc-settings#'. self::PREFIX . 'display');
167 }
168 }