PluginProbe
Route ‑ Shipping Protection / 2.2.4
Route ‑ Shipping Protection v2.2.4
2.4.19 2.4.18 2.4.17 2.4.16 2.4.15 2.4.14 2.4.13 2.4.12 2.4.11 2.4.10 2.4.9 2.4.8 2.4.7 2.4.6 2.4.5 2.4.4 2.4.3 2.4.2 2.2.4 2.2.5 2.2.6 2.2.8 2.2.9 2.3.0 2.3.1 All 153 releases
routeapp / admin / class-wc-settings-routeapp.php

class-wc-settings-routeapp.php in Route ‑ Shipping Protection 2.2.4, at admin/class-wc-settings-routeapp.php

192 lines 6.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class WC_Settings_Routeapp file.
4 *
5 * @package Routeapp\Admin
6 */
7
8 if ( ! defined( 'ABSPATH' ) ) {
9 exit;
10 }
11
12 if ( ! class_exists( 'WC_Settings_Routeapp' ) ) :
13 /**
14 * Settings class
15 *
16 * @since 1.0.0
17 */
18 class WC_Settings_Routeapp extends WC_Settings_Page {
19
20 const PRINTIFY_SHIPPING_METHOD = 'printify_shipping';
21 const PRINTIFY_SHIPPING_STANDARD = 'printify_shipping_s';
22 const PRINTIFY_SHIPPING_EXPRESS = 'printify_shipping_e';
23
24 /**
25 * Setup settings class
26 *
27 * @since 1.0
28 */
29 public function __construct() {
30
31 $this->id = 'routeapp';
32 $this->label = __( 'Route', 'routeapp' );
33 add_filter( 'woocommerce_settings_tabs_array', array( $this, 'add_settings_page' ), 20 );
34 add_action( 'woocommerce_settings_' . $this->id, array( $this, 'output' ) );
35 add_action( 'woocommerce_settings_save_' . $this->id, array( $this, 'save' ) );
36 }
37
38 public static function get_route_public_instance(){
39 global $routeapp_public;
40 return $routeapp_public;
41 }
42
43 /**
44 * Get settings array
45 *
46 * @since 1.0.0
47 * @return array Array of settings
48 */
49 public function get_settings() {
50
51 /**
52 * Filter Plugin Settings
53 *
54 * @since 1.0.0
55 * @param array $settings Array of the plugin settings
56 */
57 $tax_classes = wc_get_product_tax_class_options();
58
59 $shipping_methods_array = [];
60 $shipping_methods = WC()->shipping->get_shipping_methods();
61 foreach($shipping_methods as $shipping_method) {
62 if($shipping_method->id === self::PRINTIFY_SHIPPING_METHOD){
63 $shipping_methods_array[self::PRINTIFY_SHIPPING_STANDARD] = $shipping_method->method_title . ' Standard';
64 $shipping_methods_array[self::PRINTIFY_SHIPPING_EXPRESS] = $shipping_method->method_title . ' Express';
65 continue;
66 }
67 $shipping_methods_array[$shipping_method->id] = $shipping_method->method_title;
68 }
69
70 $routeapp_public = self::get_route_public_instance();
71 $checkout_hooks = $routeapp_public->routeapp_get_checkout_hook_options();
72
73 $settings = apply_filters( 'routeapp_settings', array(
74 array(
75 'name' => __( 'Route', 'routeapp' ),
76 'type' => 'title',
77 'desc' => '',
78 'id' => 'routeapp_route_insurance',
79 ),
80 array(
81 'name' => __( 'Public Token', 'routeapp' ),
82 'type' => 'text',
83 'desc' => "<p class='description'>Haven’t received your Tokens? <a href='https://dashboard.route.com/create-account' target='_blank'>Click here</a> to create your Route Partner Account.</p>",
84 'id' => 'routeapp_public_token',
85 'class' => 'route-environment',
86 ),
87 array(
88 'name' => __( 'Secret Token', 'routeapp' ),
89 'type' => 'text',
90 'id' => 'routeapp_secret_token',
91 'class' => 'route-environment',
92 ),
93 array(
94 'name' => __( 'Is Route Fee taxable', 'routeapp' ),
95 'type' => 'checkbox',
96 'desc' => __( 'When enabled, Route fee will be taxable', 'routeapp'),
97 'id' => 'routeapp_route_fee_taxable',
98 'default' => 'no'
99 ),
100 array(
101 'name' => __( 'Tax Class', 'routeapp' ),
102 'type' => 'select',
103 'id' => 'routeapp_taxable_class',
104 'class' => 'route-environment',
105 'options' => $tax_classes
106 ),
107 array(
108 'name' => __( 'Enable Route extra columns', 'routeapp' ),
109 'type' => 'checkbox',
110 'desc' => __( 'When enabled, add Route Charge and Route Protection columns to Orders page', 'routeapp'),
111 'id' => 'routeapp_route_enable_extra_columns',
112 'default' => 'yes'
113 ),
114 array(
115 'name' => __( 'Please select all Shipping Methods that are similar to "In Store Pickup"', 'routeapp' ),
116 'type' => 'multiselect',
117 'id' => 'routeapp_excluded_shipping_methods',
118 'class' => 'route-environment',
119 'options' => $shipping_methods_array
120 ),
121 array(
122 'name' => __( 'Please select all the order statuses that Route will use to sync orders', 'routeapp' ),
123 'type' => 'multiselect',
124 'id' => 'routeapp_included_order_statuses',
125 'class' => 'route-environment',
126 'options' => wc_get_order_statuses()
127 ),
128 array(
129 'name' => __( 'Please select all the order statuses that Route will use to cancel orders', 'routeapp' ),
130 'type' => 'multiselect',
131 'id' => 'routeapp_cancel_order_statuses',
132 'class' => 'route-environment',
133 'options' => wc_get_order_statuses()
134 ),
135 array(
136 'name' => __( 'Include order updates widget', 'routeapp' ),
137 'type' => 'checkbox',
138 'desc' => __( 'When enabled, Route\'s default order updates widget will be included', 'routeapp'),
139 'id' => 'routeapp_route_show_order_updates',
140 'default' => 'yes'
141 ),
142 array(
143 'name' => __( 'Choose the place where Route Widget will appear on checkout page', 'routeapp' ),
144 'type' => 'select',
145 'desc' => "<p class='description'>You can edit the place where the route widget will appear. You can check <a href='https://docs.woocommerce.com/wc-apidocs/hook-docs.html' target='_blank'>here</a> for further explanation about how hooks works.</p>",
146 'id' => 'routeapp_checkout_hook',
147 'class' => 'route-environment',
148 'options' => $checkout_hooks,
149 'default' => 'woocommerce_checkout_before_order_review'
150 ),
151 array(
152 'type' => 'sectionend',
153 'id' => 'route_insurance'
154 ),
155 ) );
156
157
158 /**
159 * Filter Routeapp Settings
160 *
161 * @since 1.0.0
162 * @param array $settings Array of the plugin settings
163 */
164 return apply_filters( 'woocommerce_get_settings_' . $this->id, $settings );
165
166 }
167
168 /**
169 * Output the settings
170 *
171 * @since 1.0
172 */
173 public function output() {
174
175 $settings = $this->get_settings();
176 WC_Admin_Settings::output_fields( $settings );
177 }
178
179
180 /**
181 * Save settings
182 *
183 * @since 1.0
184 */
185 public function save() {
186
187 $settings = $this->get_settings();
188 WC_Admin_Settings::save_fields( $settings );
189 }
190 }
191 endif;
192