PluginProbe ʕ •ᴥ•ʔ
WooCommerce / 10.8.1
WooCommerce v10.8.1
10.8.1 10.8.0 10.8.0-rc.1 10.8.0-beta.2 10.8.0-beta.1 7.8.0-beta.1 7.8.0-beta.2 7.8.0-rc.1 7.8.0-rc.2 7.8.1 7.8.2 7.8.3 7.8.4 7.9.0 7.9.0-beta.1 7.9.0-beta.2 7.9.0-rc.2 7.9.0-rc.3 7.9.1 7.9.2 8.0.0 8.0.0-beta.1 8.0.0-beta.2 8.0.0-rc.1 8.0.0-rc.2 8.0.1 8.0.2 8.0.3 8.0.4 8.0.5 8.1.0 8.1.0-beta.1 8.1.0-rc.1 8.1.0-rc.2 8.1.1 8.1.2 8.1.3 8.1.4 8.2.0 8.2.0-beta.1 8.2.0-rc.1 8.2.0-rc.2 8.2.1 8.2.2 8.2.3 8.2.4 8.2.5 8.3.0 8.3.0-beta.1 8.3.0-rc.1 8.3.0-rc.2 8.3.1 8.3.2 8.3.3 8.3.4 8.4.0 8.4.0-beta.1 8.4.0-rc.1 8.4.1 8.4.2 8.4.3 8.5.0 8.5.0-beta.1 8.5.0-rc.1 8.5.1 8.5.2 8.5.3 8.5.4 8.5.5 8.6.0 8.6.0-beta.1 8.6.0-rc.1 8.6.1 8.6.2 8.6.3 8.6.4 8.7.0 8.7.0-beta.1 8.7.0-beta.2 8.7.0-rc.1 8.7.1 8.7.2 8.7.3 8.8.0 8.8.0-beta.1 8.8.0-rc.1 8.8.1 8.8.2 8.8.3 8.8.4 8.8.5 8.8.6 8.8.7 8.9.0 8.9.0-beta.1 8.9.0-rc.1 8.9.1 8.9.2 8.9.3 8.9.4 8.9.5 9.0.0 9.0.0-beta.1 9.0.0-beta.2 9.0.0-rc.1 9.0.1 9.0.2 9.0.3 9.0.4 9.1.0 9.1.0-beta.1 9.1.0-rc.1 9.1.1 9.1.2 9.1.3 9.1.4 9.1.5 9.1.6 9.2.0 9.2.0-beta.1 9.2.0-rc.1 9.2.1 9.2.2 9.2.3 9.2.4 9.2.5 9.3.0 9.3.0-beta.1 9.3.0-rc.1 9.3.1 9.3.2 9.3.3 9.3.4 9.3.5 9.3.6 9.4.0 9.4.0-beta.1 9.4.0-beta.2 9.4.0-rc.1 9.4.0-rc.2 9.4.0-rc.3 9.4.0-rc.4 9.4.1 9.4.2 9.4.3 9.4.4 9.4.5 9.5.0 9.5.0-beta.1 9.5.0-beta.2 9.5.0-rc.1 9.5.1 9.5.2 9.5.3 9.5.4 9.6.0 9.6.0-beta.1 9.6.0-beta.2 9.6.0-rc.1 9.6.1 9.6.2 9.6.3 9.6.4 9.7.0 9.7.0-beta.1 9.7.0-rc.1 9.7.1 9.7.2 9.7.3 9.8.0 9.8.0-beta.1 9.8.0-rc.1 9.8.1 9.8.2 9.8.3 9.8.4 9.8.5 9.8.6 9.8.7 9.9.0 9.9.0-beta.1 9.9.0-rc.1 9.9.1 9.9.2 9.9.3 9.9.4 9.9.5 9.9.6 9.9.7 3.7.3 7.1.2 3.8.0 7.2.0 3.8.0-beta.1 7.2.0-beta.1 3.8.0-rc.1 7.2.0-beta.2 3.8.0-rc.2 7.2.0-rc.1 3.8.1 7.2.0-rc.2 3.8.2 7.2.1 3.8.3 7.2.2 3.9.0 7.2.3 3.9.0-beta.1 7.2.4 3.9.0-beta.2 7.3.0 3.9.0-rc.1 7.3.0-beta.1 3.9.0-rc.2 7.3.0-beta.2 3.9.0-rc.3 7.3.0-rc.1 3.9.0-rc.4 7.3.0-rc.2 3.9.1 7.3.1 3.9.2 7.4.0 3.9.3 7.4.0-beta.1 3.9.4 7.4.0-beta.2 3.9.5 7.4.0-rc.1 4.0.0 7.4.0-rc.2 4.0.0-beta.1 7.4.1 4.0.0-rc.1 7.4.2 4.0.0-rc.2 7.5.0 4.0.1 7.5.0-beta.1 4.0.2 7.5.0-beta.2 4.0.3 7.5.0-rc.1 4.0.4 7.5.1 4.1.0 7.5.2 4.1.0-beta.1 7.6.0 4.1.0-beta.2 7.6.0-beta.1 4.1.0-rc.1 7.6.0-beta.2 4.1.0-rc.2 7.6.0-rc.1 4.1.1 7.6.0-rc.2 4.1.2 7.6.0-rc.3 4.1.3 7.6.1 4.1.4 7.6.2 4.2.0 7.7.0 4.2.0-RC.1 7.7.0-beta.1 4.2.0-RC.2 7.7.0-beta.2 4.2.0-beta.1 7.7.0-rc.1 4.2.1 7.7.1 4.2.2 7.7.2 4.2.3 7.7.3 4.2.4 7.8.0 4.2.5 4.3.0 4.3.0-beta.1 4.3.0-rc.1 4.3.0-rc.2 4.3.0-rc.3 4.3.1 4.3.2 4.3.3 4.3.4 4.3.5 4.3.6 4.4.0 4.4.0-beta.1 4.4.0-rc.1 4.4.1 4.4.2 4.4.3 4.4.4 4.5.0 4.5.0-beta.1 4.5.0-rc.1 4.5.0-rc.3 4.5.1 4.5.2 4.5.3 4.5.4 4.5.5 4.6.0 4.6.0-beta.1 4.6.0-rc.1 4.6.1 4.6.2 4.6.3 4.6.4 4.6.5 4.7.0 4.7.0-beta.1 4.7.0-beta.2 4.7.0-rc.1 4.7.1 4.7.1-beta.1 4.7.2 4.7.3 4.7.4 4.8.0 4.8.0-beta.1 4.8.0-rc.1 4.8.0-rc.2 4.8.1 4.8.2 4.8.3 4.9.0 4.9.0-beta.1 4.9.0-rc.1 4.9.0-rc.2 4.9.1 4.9.2 4.9.3 4.9.4 4.9.5 5.0.0 5.0.0-beta.1 5.0.0-beta.2 5.0.0-rc.1 5.0.0-rc.2 5.0.0-rc.3 5.0.1 5.0.2 5.0.3 5.1.0 5.1.0-beta.1 5.1.0-rc.1 trunk 5.1.1 10.0.0 5.1.2 10.0.0-rc.1 5.1.3 10.0.0-rc.2 5.2.0 10.0.1 5.2.0-beta.1 10.0.2 5.2.0-rc.1 10.0.3 5.2.0-rc.2 10.0.4 5.2.1 10.0.5 5.2.2 10.0.6 5.2.3 10.1.0 5.2.4 10.1.0-rc.1 5.2.5 10.1.0-rc.2 5.3.0 10.1.0-rc.3 5.3.0-beta.1 10.1.0-rc.4 5.3.0-rc.1 10.1.1 5.3.0-rc.2 10.1.2 5.3.1 10.1.3 5.3.2 10.1.4 5.3.3 10.2.0 5.4.0 10.2.0-beta.1 5.4.0-beta.1 10.2.0-beta.2 5.4.0-rc.1 10.2.0-rc.1 5.4.1 10.2.1 5.4.2 10.2.2 5.4.3 10.2.3 5.4.4 10.2.4 5.4.5 10.3.0 5.5.0 10.3.0-beta.1 5.5.0-beta.1 10.3.0-beta.2 5.5.0-rc.1 10.3.0-rc.1 5.5.0-rc.2 10.3.0-rc.2 5.5.1 10.3.1 5.5.2 10.3.2 5.5.3 10.3.3 5.5.4 10.3.4 5.5.5 10.3.5 5.6.0 10.3.6 5.6.0-beta.1 10.3.7 5.6.0-rc.1 10.3.8 5.6.0-rc.2 10.4.0 5.6.1 10.4.0-beta.1 5.6.2 10.4.0-beta.2 5.6.3 10.4.0-rc.1 5.7.0 10.4.1 5.7.0-beta.1 10.4.2 5.7.0-rc.1 10.4.3 5.7.1 10.4.4 5.7.2 10.5.0 5.7.3 10.5.0-beta.1 5.8.0 10.5.0-beta.2 5.8.0-beta.1 10.5.0-rc.1 5.8.0-beta.2 10.5.0-rc.2 5.8.0-rc.1 10.5.0-rc.3 5.8.1 10.5.1 5.8.2 10.5.2 5.9.0 10.5.3 5.9.0-beta.1 10.6.0 5.9.0-rc.1 10.6.0-beta.1 5.9.0-rc.2 10.6.0-beta.2 5.9.1 10.6.0-rc.1 5.9.2 10.6.1 6.0.0 10.6.2 6.0.0-beta.1 10.7.0 6.0.0-rc.1 10.7.0-beta.1 6.0.1 10.7.0-beta.2 6.0.2 10.7.0-rc.1 6.1.0 3.0.0 6.1.0-beta.1 3.0.1 6.1.0-rc.1 3.0.2 6.1.0-rc.2 3.0.3 6.1.1 3.0.4 6.1.2 3.0.5 6.1.3 3.0.6 6.2.0 3.0.7 6.2.0-beta.1 3.0.8 6.2.0-rc.1 3.0.9 6.2.0-rc.2 3.1.0 6.2.1 3.1.1 6.2.2 3.1.2 6.2.3 3.2.0 6.3.0 3.2.1 6.3.0-beta.1 3.2.2 6.3.0-rc.1 3.2.3 6.3.0-rc.2 3.2.4 6.3.1 3.2.5 6.3.2 3.2.6 6.4.0 3.3.0 6.4.0-beta.1 3.3.1 6.4.0-rc.1 3.3.2 6.4.1 3.3.2-rc.1 6.4.2 3.3.3 6.5.0 3.3.4 6.5.0-beta.1 3.3.5 6.5.0-rc.1 3.3.6 6.5.0-rc.2 3.4.0 6.5.1 3.4.0-beta.1 6.5.2 3.4.0-rc.2 6.6.0 3.4.1 6.6.0-beta.1 3.4.2 6.6.0-rc.1 3.4.3 6.6.0-rc.2 3.4.4 6.6.1 3.4.5 6.6.2 3.4.6 6.7.0 3.4.7 6.7.0-beta.1 3.4.8 6.7.0-beta.2 3.5.0 6.7.0-rc.1 3.5.0-beta.1 6.7.1 3.5.0-rc.1 6.8.0 3.5.0-rc.2 6.8.0-beta.1 3.5.1 6.8.0-beta.2 3.5.10 6.8.0-rc.1 3.5.2 6.8.1 3.5.3 6.8.2 3.5.4 6.8.3 3.5.5 6.9.0 3.5.6 6.9.0-beta.1 3.5.7 6.9.0-beta.2 3.5.8 6.9.0-rc.1 3.5.9 6.9.1 3.6.0 6.9.2 3.6.0-beta.1 6.9.3 3.6.0-rc.1 6.9.4 3.6.0-rc.2 6.9.5 3.6.0-rc.3 7.0.0 3.6.1 7.0.0-beta.1 3.6.2 7.0.0-beta.2 3.6.3 7.0.0-beta.3 3.6.4 7.0.0-rc.1 3.6.5 7.0.0-rc.2 3.6.6 7.0.1 3.6.7 7.0.2 3.7.0 7.1.0 3.7.0-beta.1 7.1.0-beta.1 3.7.0-rc.1 7.1.0-beta.2 3.7.0-rc.2 7.1.0-rc.1 3.7.1 7.1.0-rc.2 3.7.2 7.1.1
woocommerce / includes / admin / class-wc-admin-setup-wizard.php
woocommerce / includes / admin Last commit date
helper 1 month ago importers 1 year ago list-tables 4 months ago marketplace-suggestions 10 months ago meta-boxes 1 month ago notes 1 month ago plugin-updates 2 years ago reports 2 months ago settings 1 week ago views 2 months ago class-wc-admin-addons.php 7 months ago class-wc-admin-api-keys-table-list.php 2 years ago class-wc-admin-api-keys.php 10 months ago class-wc-admin-assets.php 1 month ago class-wc-admin-attributes.php 3 years ago class-wc-admin-brands.php 3 months ago class-wc-admin-customize.php 5 years ago class-wc-admin-dashboard-setup.php 10 months ago class-wc-admin-dashboard.php 3 months ago class-wc-admin-duplicate-product.php 4 months ago class-wc-admin-exporters.php 1 year ago class-wc-admin-help.php 2 years ago class-wc-admin-importers.php 10 months ago class-wc-admin-log-table-list.php 3 months ago class-wc-admin-marketplace-promotions.php 3 months ago class-wc-admin-menus.php 3 months ago class-wc-admin-meta-boxes.php 1 year ago class-wc-admin-notices.php 1 month ago class-wc-admin-permalink-settings.php 5 years ago class-wc-admin-pointers.php 3 years ago class-wc-admin-post-types.php 1 year ago class-wc-admin-profile.php 1 year ago class-wc-admin-reports.php 3 months ago class-wc-admin-settings.php 2 months ago class-wc-admin-setup-wizard.php 3 months ago class-wc-admin-status.php 1 year ago class-wc-admin-taxonomies.php 6 months ago class-wc-admin-upload-downloadable-product.php 2 years ago class-wc-admin-webhooks-table-list.php 1 year ago class-wc-admin-webhooks.php 10 months ago class-wc-admin.php 2 months ago wc-admin-functions.php 6 months ago wc-meta-box-functions.php 1 year ago woocommerce-legacy-reports.php 1 year ago
class-wc-admin-setup-wizard.php
2371 lines
1 <?php
2 /**
3 * Setup Wizard Class
4 *
5 * Takes new users through some basic steps to setup their store.
6 *
7 * @package WooCommerce\Admin
8 * @version 2.6.0
9 * @deprecated 4.6.0
10 */
11
12 use Automattic\Jetpack\Constants;
13
14 if ( ! defined( 'ABSPATH' ) ) {
15 exit;
16 }
17
18 /**
19 * WC_Admin_Setup_Wizard class.
20 */
21 class WC_Admin_Setup_Wizard {
22
23 /**
24 * Current step
25 *
26 * @var string
27 */
28 private $step = '';
29
30 /**
31 * Steps for the setup wizard
32 *
33 * @var array
34 */
35 private $steps = array();
36
37 /**
38 * Actions to be executed after the HTTP response has completed
39 *
40 * @var array
41 */
42 private $deferred_actions = array();
43
44 /**
45 * Tweets user can optionally send after install
46 *
47 * @var array
48 */
49 private $tweets = array(
50 'Someone give me woo-t, I just set up a new store with #WordPress and @WooCommerce!',
51 'Someone give me high five, I just set up a new store with #WordPress and @WooCommerce!',
52 );
53
54 /**
55 * The version of WordPress required to run the WooCommerce Admin plugin
56 *
57 * @var string
58 */
59 private $wc_admin_plugin_minimum_wordpress_version = '5.3';
60
61 /**
62 * Hook in tabs.
63 *
64 * @deprecated 4.6.0
65 * @return void
66 */
67 public function __construct() {
68 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
69 }
70
71 /**
72 * Add admin menus/screens.
73 *
74 * @deprecated 4.6.0
75 * @return void
76 */
77 public function admin_menus() {
78 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
79 add_dashboard_page( '', '', 'manage_options', 'wc-setup', '' );
80 }
81
82 /**
83 * The theme "extra" should only be shown if the current user can modify themes
84 * and the store doesn't already have a WooCommerce theme.
85 *
86 * @deprecated 4.6.0
87 * @return boolean
88 */
89 protected function should_show_theme() {
90 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
91 $support_woocommerce = current_theme_supports( 'woocommerce' ) && ! wc_is_wp_default_theme_active();
92
93 return (
94 current_user_can( 'install_themes' ) &&
95 current_user_can( 'switch_themes' ) &&
96 ! is_multisite() &&
97 ! $support_woocommerce
98 );
99 }
100
101 /**
102 * The "automated tax" extra should only be shown if the current user can
103 * install plugins and the store is in a supported country.
104 *
105 * @deprecated 4.6.0
106 * @return bool
107 */
108 protected function should_show_automated_tax() {
109 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
110 if ( ! current_user_can( 'install_plugins' ) ) {
111 return false;
112 }
113
114 $country_code = WC()->countries->get_base_country();
115 // https://developers.taxjar.com/api/reference/#countries .
116 $tax_supported_countries = array_merge(
117 array( 'US', 'CA', 'AU', 'GB' ),
118 WC()->countries->get_european_union_countries()
119 );
120
121 return in_array( $country_code, $tax_supported_countries, true );
122 }
123
124 /**
125 * Should we show the MailChimp install option?
126 * True only if the user can install plugins.
127 *
128 * @deprecated 4.6.0
129 * @return boolean
130 */
131 protected function should_show_mailchimp() {
132 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
133 return current_user_can( 'install_plugins' );
134 }
135
136 /**
137 * Should we show the Facebook install option?
138 * True only if the user can install plugins,
139 * and up until the end date of the recommendation.
140 *
141 * @deprecated 4.6.0
142 * @return boolean
143 */
144 protected function should_show_facebook() {
145 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
146 return current_user_can( 'install_plugins' );
147 }
148
149 /**
150 * Is the WooCommerce Admin actively included in the WooCommerce core?
151 * Based on presence of a basic WC Admin function.
152 *
153 * @deprecated 4.6.0
154 * @return boolean
155 */
156 protected function is_wc_admin_active() {
157 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
158 return function_exists( 'wc_admin_url' );
159 }
160
161 /**
162 * Should we show the WooCommerce Admin install option?
163 * True only if the user can install plugins,
164 * and is running the correct version of WordPress.
165 *
166 * @see WC_Admin_Setup_Wizard::$wc_admin_plugin_minimum_wordpress_version
167 *
168 * @deprecated 4.6.0
169 * @return boolean
170 */
171 protected function should_show_wc_admin() {
172 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
173 $wordpress_minimum_met = version_compare( get_bloginfo( 'version' ), $this->wc_admin_plugin_minimum_wordpress_version, '>=' );
174 return current_user_can( 'install_plugins' ) && $wordpress_minimum_met && ! $this->is_wc_admin_active();
175 }
176
177 /**
178 * Should we show the new WooCommerce Admin onboarding experience?
179 *
180 * @deprecated 4.6.0
181 * @return boolean
182 */
183 protected function should_show_wc_admin_onboarding() {
184 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
185 // As of WooCommerce 4.1, all new sites should use the latest OBW from wc-admin package.
186 // This filter will allow for forcing the old wizard while we migrate e2e tests.
187 return ! apply_filters( 'woocommerce_setup_wizard_force_legacy', false );
188 }
189
190 /**
191 * Should we display the 'Recommended' step?
192 * True if at least one of the recommendations will be displayed.
193 *
194 * @deprecated 4.6.0
195 * @return boolean
196 */
197 protected function should_show_recommended_step() {
198 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
199 return $this->should_show_theme()
200 || $this->should_show_automated_tax()
201 || $this->should_show_mailchimp()
202 || $this->should_show_facebook()
203 || $this->should_show_wc_admin();
204 }
205
206 /**
207 * Register/enqueue scripts and styles for the Setup Wizard.
208 *
209 * Hooked onto 'admin_enqueue_scripts'.
210 *
211 * @deprecated 4.6.0
212 * @return void
213 */
214 public function enqueue_scripts() {
215 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
216 }
217
218 /**
219 * Show the setup wizard.
220 *
221 * @deprecated 4.6.0
222 * @return void
223 */
224 public function setup_wizard() {
225 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
226 if ( empty( $_GET['page'] ) || 'wc-setup' !== $_GET['page'] ) { // WPCS: CSRF ok, input var ok.
227 return;
228 }
229 $default_steps = array(
230 'new_onboarding' => array(
231 'name' => '',
232 'view' => array( $this, 'wc_setup_new_onboarding' ),
233 'handler' => array( $this, 'wc_setup_new_onboarding_save' ),
234 ),
235 'store_setup' => array(
236 'name' => __( 'Store setup', 'woocommerce' ),
237 'view' => array( $this, 'wc_setup_store_setup' ),
238 'handler' => array( $this, 'wc_setup_store_setup_save' ),
239 ),
240 'payment' => array(
241 'name' => __( 'Payment', 'woocommerce' ),
242 'view' => array( $this, 'wc_setup_payment' ),
243 'handler' => array( $this, 'wc_setup_payment_save' ),
244 ),
245 'shipping' => array(
246 'name' => __( 'Shipping', 'woocommerce' ),
247 'view' => array( $this, 'wc_setup_shipping' ),
248 'handler' => array( $this, 'wc_setup_shipping_save' ),
249 ),
250 'recommended' => array(
251 'name' => __( 'Recommended', 'woocommerce' ),
252 'view' => array( $this, 'wc_setup_recommended' ),
253 'handler' => array( $this, 'wc_setup_recommended_save' ),
254 ),
255 'activate' => array(
256 'name' => __( 'Activate', 'woocommerce' ),
257 'view' => array( $this, 'wc_setup_activate' ),
258 'handler' => array( $this, 'wc_setup_activate_save' ),
259 ),
260 'next_steps' => array(
261 'name' => __( 'Ready!', 'woocommerce' ),
262 'view' => array( $this, 'wc_setup_ready' ),
263 'handler' => '',
264 ),
265 );
266
267 // Hide the new/improved onboarding experience screen if the user is not part of the a/b test.
268 if ( ! $this->should_show_wc_admin_onboarding() ) {
269 unset( $default_steps['new_onboarding'] );
270 }
271
272 // Hide recommended step if nothing is going to be shown there.
273 if ( ! $this->should_show_recommended_step() ) {
274 unset( $default_steps['recommended'] );
275 }
276
277 // Hide shipping step if the store is selling digital products only.
278 if ( 'virtual' === get_option( 'woocommerce_product_type' ) ) {
279 unset( $default_steps['shipping'] );
280 }
281
282 // Hide activate section when the user does not have capabilities to install plugins, think multiside admins not being a super admin.
283 if ( ! current_user_can( 'install_plugins' ) ) {
284 unset( $default_steps['activate'] );
285 }
286
287 $this->steps = apply_filters( 'woocommerce_setup_wizard_steps', $default_steps );
288 $this->step = isset( $_GET['step'] ) ? sanitize_key( $_GET['step'] ) : current( array_keys( $this->steps ) ); // WPCS: CSRF ok, input var ok.
289
290 // @codingStandardsIgnoreStart
291 if ( ! empty( $_POST['save_step'] ) && isset( $this->steps[ $this->step ]['handler'] ) ) {
292 call_user_func( $this->steps[ $this->step ]['handler'], $this );
293 }
294 // @codingStandardsIgnoreEnd
295
296 ob_start();
297 $this->setup_wizard_header();
298 $this->setup_wizard_steps();
299 $this->setup_wizard_content();
300 $this->setup_wizard_footer();
301 exit;
302 }
303
304 /**
305 * Get the URL for the next step's screen.
306 *
307 * @param string $step slug (default: current step).
308 * @return string URL for next step if a next step exists.
309 * Admin URL if it's the last step.
310 * Empty string on failure.
311 *
312 * @deprecated 4.6.0
313 * @since 3.0.0
314 */
315 public function get_next_step_link( $step = '' ) {
316 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
317 if ( ! $step ) {
318 $step = $this->step;
319 }
320
321 $keys = array_keys( $this->steps );
322 if ( end( $keys ) === $step ) {
323 return admin_url();
324 }
325
326 $step_index = array_search( $step, $keys, true );
327 if ( false === $step_index ) {
328 return '';
329 }
330
331 return add_query_arg( 'step', $keys[ $step_index + 1 ], remove_query_arg( 'activate_error' ) );
332 }
333
334 /**
335 * Setup Wizard Header.
336 *
337 * @deprecated 4.6.0
338 * @return void
339 */
340 public function setup_wizard_header() {
341 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
342 // same as default WP from wp-admin/admin-header.php.
343 $wp_version_class = 'branch-' . str_replace( array( '.', ',' ), '-', floatval( get_bloginfo( 'version' ) ) );
344
345 set_current_screen();
346 ?>
347 <!DOCTYPE html>
348 <html <?php language_attributes(); ?>>
349 <head>
350 <meta name="viewport" content="width=device-width" />
351 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
352 <title><?php esc_html_e( 'WooCommerce &rsaquo; Setup Wizard', 'woocommerce' ); ?></title>
353 <?php do_action( 'admin_enqueue_scripts' ); ?>
354 <?php wp_print_scripts( 'wc-setup' ); ?>
355 <?php do_action( 'admin_print_styles' ); ?>
356 <?php do_action( 'admin_head' ); ?>
357 </head>
358 <body class="wc-setup wp-core-ui <?php echo esc_attr( 'wc-setup-step__' . $this->step ); ?> <?php echo esc_attr( $wp_version_class ); ?>">
359 <h1 class="wc-logo"><a href="https://woocommerce.com/"><img src="<?php echo esc_url( WC()->plugin_url() ); ?>/assets/images/woocommerce_logo.png" alt="<?php esc_attr_e( 'WooCommerce', 'woocommerce' ); ?>" /></a></h1>
360 <?php
361 }
362
363 /**
364 * Setup Wizard Footer.
365 *
366 * @deprecated 4.6.0
367 * @return void
368 */
369 public function setup_wizard_footer() {
370 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
371 $current_step = $this->step;
372 ?>
373 <?php if ( 'new_onboarding' === $current_step || 'store-setup' === $current_step ) : ?>
374 <a class="wc-setup-footer-links" href="<?php echo esc_url( admin_url() ); ?>"><?php esc_html_e( 'Not right now', 'woocommerce' ); ?></a>
375 <?php elseif ( 'recommended' === $current_step || 'activate' === $current_step ) : ?>
376 <a class="wc-setup-footer-links" href="<?php echo esc_url( $this->get_next_step_link() ); ?>"><?php esc_html_e( 'Skip this step', 'woocommerce' ); ?></a>
377 <?php endif; ?>
378 <?php do_action( 'woocommerce_setup_footer' ); ?>
379 </body>
380 </html>
381 <?php
382 }
383
384 /**
385 * Output the steps.
386 *
387 * @deprecated 4.6.0
388 * @return void
389 */
390 public function setup_wizard_steps() {
391 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
392 $output_steps = $this->steps;
393 $selected_features = array_filter( $this->wc_setup_activate_get_feature_list() );
394
395 // Hide the activate step if Jetpack is already active, unless WooCommerce Services
396 // features are selected, or unless the Activate step was already taken.
397 if ( class_exists( 'Jetpack' ) && Jetpack::is_active() && empty( $selected_features ) && 'yes' !== get_transient( 'wc_setup_activated' ) ) {
398 unset( $output_steps['activate'] );
399 }
400
401 unset( $output_steps['new_onboarding'] );
402
403 ?>
404 <ol class="wc-setup-steps">
405 <?php
406 foreach ( $output_steps as $step_key => $step ) {
407 $is_completed = array_search( $this->step, array_keys( $this->steps ), true ) > array_search( $step_key, array_keys( $this->steps ), true );
408
409 if ( $step_key === $this->step ) {
410 ?>
411 <li class="active"><?php echo esc_html( $step['name'] ); ?></li>
412 <?php
413 } elseif ( $is_completed ) {
414 ?>
415 <li class="done">
416 <a href="<?php echo esc_url( add_query_arg( 'step', $step_key, remove_query_arg( 'activate_error' ) ) ); ?>"><?php echo esc_html( $step['name'] ); ?></a>
417 </li>
418 <?php
419 } else {
420 ?>
421 <li><?php echo esc_html( $step['name'] ); ?></li>
422 <?php
423 }
424 }
425 ?>
426 </ol>
427 <?php
428 }
429
430 /**
431 * Output the content for the current step.
432 *
433 * @deprecated 4.6.0
434 * @return void
435 */
436 public function setup_wizard_content() {
437 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
438 echo '<div class="wc-setup-content">';
439 if ( ! empty( $this->steps[ $this->step ]['view'] ) ) {
440 call_user_func( $this->steps[ $this->step ]['view'], $this );
441 }
442 echo '</div>';
443 }
444
445 /**
446 * Display's a prompt for users to try out the new improved WooCommerce onboarding experience in WooCommerce Admin.
447 *
448 * @deprecated 4.6.0
449 * @return void
450 */
451 public function wc_setup_new_onboarding() {
452 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
453 ?>
454 <div class="wc-setup-step__new_onboarding-wrapper">
455 <p class="wc-setup-step__new_onboarding-welcome"><?php esc_html_e( 'Welcome to', 'woocommerce' ); ?></p>
456 <h1 class="wc-logo"><a href="https://woocommerce.com/"><img src="<?php echo esc_url( WC()->plugin_url() ); ?>/assets/images/woocommerce_logo.png" alt="<?php esc_attr_e( 'WooCommerce', 'woocommerce' ); ?>" /></a></h1>
457 <p><?php esc_html_e( 'Get your store up and running more quickly with our new and improved setup experience', 'woocommerce' ); ?></p>
458
459 <form method="post" class="activate-new-onboarding">
460 <?php wp_nonce_field( 'wc-setup' ); ?>
461 <input type="hidden" name="save_step" value="new_onboarding" />
462 <p class="wc-setup-actions step">
463 <button class="button-primary button button-large" value="<?php esc_attr_e( 'Yes please', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Yes please', 'woocommerce' ); ?></button>
464 </p>
465 </form>
466 <?php if ( ! $this->is_wc_admin_active() ) : ?>
467 <p class="wc-setup-step__new_onboarding-plugin-info"><?php esc_html_e( 'The "WooCommerce Admin" plugin will be installed and activated', 'woocommerce' ); ?></p>
468 <?php endif; ?>
469 </div>
470 <?php
471 }
472
473 /**
474 * Installs WooCommerce admin and redirects to the new onboarding experience.
475 *
476 * @deprecated 4.6.0
477 * @return void
478 */
479 public function wc_setup_new_onboarding_save() {
480 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
481 }
482
483 /**
484 * Initial "store setup" step.
485 * Location, product type, page setup, and tracking opt-in.
486 *
487 * @return void
488 */
489 public function wc_setup_store_setup() {
490 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
491 $address = WC()->countries->get_base_address();
492 $address_2 = WC()->countries->get_base_address_2();
493 $city = WC()->countries->get_base_city();
494 $state = WC()->countries->get_base_state();
495 $country = WC()->countries->get_base_country();
496 $postcode = WC()->countries->get_base_postcode();
497 $currency = get_option( 'woocommerce_currency', 'USD' );
498 $product_type = get_option( 'woocommerce_product_type', 'both' );
499 $sell_in_person = get_option( 'woocommerce_sell_in_person', 'none_selected' );
500
501 if ( empty( $country ) ) {
502 $user_location = WC_Geolocation::geolocate_ip();
503 $country = $user_location['country'];
504 $state = $user_location['state'];
505 }
506
507 $locale_info = include WC()->plugin_path() . '/i18n/locale-info.php';
508 $currency_by_country = wp_list_pluck( $locale_info, 'currency_code' );
509 ?>
510 <form method="post" class="address-step">
511 <input type="hidden" name="save_step" value="store_setup" />
512 <?php wp_nonce_field( 'wc-setup' ); ?>
513 <p class="store-setup"><?php esc_html_e( 'The following wizard will help you configure your store and get you started quickly.', 'woocommerce' ); ?></p>
514
515 <div class="store-address-container">
516
517 <label for="store_country" class="location-prompt"><?php esc_html_e( 'Where is your store based?', 'woocommerce' ); ?></label>
518 <select id="store_country" name="store_country" required data-placeholder="<?php esc_attr_e( 'Choose a country / region&hellip;', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'Country / Region', 'woocommerce' ); ?>" class="location-input wc-enhanced-select dropdown">
519 <?php foreach ( WC()->countries->get_countries() as $code => $label ) : ?>
520 <option <?php selected( $code, $country ); ?> value="<?php echo esc_attr( $code ); ?>"><?php echo esc_html( $label ); ?></option>
521 <?php endforeach; ?>
522 </select>
523
524 <label class="location-prompt" for="store_address"><?php esc_html_e( 'Address', 'woocommerce' ); ?></label>
525 <input type="text" id="store_address" class="location-input" name="store_address" required value="<?php echo esc_attr( $address ); ?>" />
526
527 <label class="location-prompt" for="store_address_2"><?php esc_html_e( 'Address line 2', 'woocommerce' ); ?></label>
528 <input type="text" id="store_address_2" class="location-input" name="store_address_2" value="<?php echo esc_attr( $address_2 ); ?>" />
529
530 <div class="city-and-postcode">
531 <div>
532 <label class="location-prompt" for="store_city"><?php esc_html_e( 'City', 'woocommerce' ); ?></label>
533 <input type="text" id="store_city" class="location-input" name="store_city" required value="<?php echo esc_attr( $city ); ?>" />
534 </div>
535 <div class="store-state-container hidden">
536 <label for="store_state" class="location-prompt">
537 <?php esc_html_e( 'State', 'woocommerce' ); ?>
538 </label>
539 <select id="store_state" name="store_state" data-placeholder="<?php esc_attr_e( 'Choose a state&hellip;', 'woocommerce' ); ?>" aria-label="<?php esc_attr_e( 'State', 'woocommerce' ); ?>" class="location-input wc-enhanced-select dropdown"></select>
540 </div>
541 <div>
542 <label class="location-prompt" for="store_postcode"><?php esc_html_e( 'Postcode / ZIP', 'woocommerce' ); ?></label>
543 <input type="text" id="store_postcode" class="location-input" name="store_postcode" required value="<?php echo esc_attr( $postcode ); ?>" />
544 </div>
545 </div>
546 </div>
547
548 <div class="store-currency-container">
549 <label class="location-prompt" for="currency_code">
550 <?php esc_html_e( 'What currency do you accept payments in?', 'woocommerce' ); ?>
551 </label>
552 <select
553 id="currency_code"
554 name="currency_code"
555 required
556 data-placeholder="<?php esc_attr_e( 'Choose a currency&hellip;', 'woocommerce' ); ?>"
557 class="location-input wc-enhanced-select dropdown"
558 >
559 <option value=""><?php esc_html_e( 'Choose a currency&hellip;', 'woocommerce' ); ?></option>
560 <?php foreach ( get_woocommerce_currencies() as $code => $name ) : ?>
561 <option value="<?php echo esc_attr( $code ); ?>" <?php selected( $currency, $code ); ?>>
562 <?php
563 $symbol = get_woocommerce_currency_symbol( $code );
564
565 if ( $symbol === $code ) {
566 /* translators: 1: currency name 2: currency code */
567 echo esc_html( sprintf( __( '%1$s (%2$s)', 'woocommerce' ), $name, $code ) );
568 } else {
569 /* translators: 1: currency name 2: currency symbol, 3: currency code */
570 echo esc_html( sprintf( __( '%1$s (%2$s %3$s)', 'woocommerce' ), $name, get_woocommerce_currency_symbol( $code ), $code ) );
571 }
572 ?>
573 </option>
574 <?php endforeach; ?>
575 </select>
576 <script type="text/javascript">
577 var wc_setup_currencies = JSON.parse( decodeURIComponent( '<?php echo rawurlencode( wp_json_encode( $currency_by_country ) ); ?>' ) );
578 var wc_base_state = "<?php echo esc_js( $state ); ?>";
579 </script>
580 </div>
581
582 <div class="product-type-container">
583 <label class="location-prompt" for="product_type">
584 <?php esc_html_e( 'What type of products do you plan to sell?', 'woocommerce' ); ?>
585 </label>
586 <select id="product_type" name="product_type" required class="location-input wc-enhanced-select dropdown">
587 <option value="both" <?php selected( $product_type, 'both' ); ?>><?php esc_html_e( 'I plan to sell both physical and digital products', 'woocommerce' ); ?></option>
588 <option value="physical" <?php selected( $product_type, 'physical' ); ?>><?php esc_html_e( 'I plan to sell physical products', 'woocommerce' ); ?></option>
589 <option value="virtual" <?php selected( $product_type, 'virtual' ); ?>><?php esc_html_e( 'I plan to sell digital products', 'woocommerce' ); ?></option>
590 </select>
591 </div>
592
593 <div class="sell-in-person-container">
594 <input
595 type="checkbox"
596 id="woocommerce_sell_in_person"
597 name="sell_in_person"
598 value="yes"
599 <?php checked( $sell_in_person, true ); ?>
600 />
601 <label class="location-prompt" for="woocommerce_sell_in_person">
602 <?php esc_html_e( 'I will also be selling products or services in person.', 'woocommerce' ); ?>
603 </label>
604 </div>
605
606 <input type="checkbox" id="wc_tracker_checkbox" name="wc_tracker_checkbox" value="yes" <?php checked( 'yes', get_option( 'woocommerce_allow_tracking', 'no' ) ); ?> />
607
608 <?php $this->tracking_modal(); ?>
609
610 <p class="wc-setup-actions step">
611 <button class="button-primary button button-large" value="<?php esc_attr_e( "Let's go!", 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( "Let's go!", 'woocommerce' ); ?></button>
612 </p>
613 </form>
614 <?php
615 }
616
617 /**
618 * Template for the usage tracking modal.
619 *
620 * @deprecated 4.6.0
621 * @return void
622 */
623 public function tracking_modal() {
624 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
625 ?>
626 <script type="text/template" id="tmpl-wc-modal-tracking-setup">
627 <div class="wc-backbone-modal woocommerce-tracker">
628 <div class="wc-backbone-modal-content">
629 <section class="wc-backbone-modal-main" role="main">
630 <header class="wc-backbone-modal-header">
631 <h1><?php esc_html_e( 'Help improve WooCommerce with usage tracking', 'woocommerce' ); ?></h1>
632 </header>
633 <article>
634 <p>
635 <?php
636 printf(
637 wp_kses(
638 /* translators: %1$s: usage tracking help link */
639 __( 'Learn more about how usage tracking works, and how you\'ll be helping in our <a href="%1$s" target="_blank">usage tracking documentation</a>.', 'woocommerce' ),
640 array(
641 'a' => array(
642 'href' => array(),
643 'target' => array(),
644 ),
645 )
646 ),
647 'https://woocommerce.com/usage-tracking/'
648 );
649 ?>
650 </p>
651 <p class="woocommerce-tracker-checkbox">
652 <input type="checkbox" id="wc_tracker_checkbox_dialog" name="wc_tracker_checkbox_dialog" value="yes" <?php checked( 'yes', get_option( 'woocommerce_allow_tracking', 'no' ) ); ?> />
653 <label for="wc_tracker_checkbox_dialog"><?php esc_html_e( 'Enable usage tracking and help improve WooCommerce', 'woocommerce' ); ?></label>
654 </p>
655 </article>
656 <footer>
657 <div class="inner">
658 <button class="button button-primary button-large" id="wc_tracker_submit" aria-label="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>"><?php esc_html_e( 'Continue', 'woocommerce' ); ?></button>
659 </div>
660 </footer>
661 </section>
662 </div>
663 </div>
664 <div class="wc-backbone-modal-backdrop modal-close"></div>
665 </script>
666 <?php
667 }
668
669 /**
670 * Save initial store settings.
671 *
672 * @deprecated 4.6.0
673 * @return void
674 */
675 public function wc_setup_store_setup_save() {
676 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
677 }
678
679 /**
680 * Finishes replying to the client, but keeps the process running for further (async) code execution.
681 *
682 * @see https://core.trac.wordpress.org/ticket/41358 .
683 * @return void
684 */
685 protected function close_http_connection() {
686 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
687 // Only 1 PHP process can access a session object at a time, close this so the next request isn't kept waiting.
688 // @codingStandardsIgnoreStart
689 if ( session_id() ) {
690 session_write_close();
691 }
692 // @codingStandardsIgnoreEnd
693
694 wc_set_time_limit( 0 );
695
696 // fastcgi_finish_request is the cleanest way to send the response and keep the script running, but not every server has it.
697 if ( is_callable( 'fastcgi_finish_request' ) ) {
698 fastcgi_finish_request();
699 } else {
700 // Fallback: send headers and flush buffers.
701 if ( ! headers_sent() ) {
702 header( 'Connection: close' );
703 }
704 @ob_end_flush(); // @codingStandardsIgnoreLine.
705 flush();
706 }
707 }
708
709 /**
710 * Function called after the HTTP request is finished, so it's executed without the client having to wait for it.
711 *
712 * @see WC_Admin_Setup_Wizard::install_plugin
713 * @see WC_Admin_Setup_Wizard::install_theme
714 *
715 * @deprecated 4.6.0
716 * @return void
717 */
718 public function run_deferred_actions() {
719 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
720 $this->close_http_connection();
721 foreach ( $this->deferred_actions as $action ) {
722 $action['func']( ...$action['args'] );
723
724 // Clear the background installation flag if this is a plugin.
725 if (
726 isset( $action['func'][1] ) &&
727 'background_installer' === $action['func'][1] &&
728 isset( $action['args'][0] )
729 ) {
730 delete_option( 'woocommerce_setup_background_installing_' . $action['args'][0] );
731 }
732 }
733 }
734
735 /**
736 * Helper method to queue the background install of a plugin.
737 *
738 * @param string $plugin_id Plugin id used for background install.
739 * @param array $plugin_info Plugin info array containing name and repo-slug, and optionally file if different from [repo-slug].php.
740 *
741 * @deprecated 4.6.0
742 * @return void
743 */
744 protected function install_plugin( $plugin_id, $plugin_info ) {
745 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
746 // Make sure we don't trigger multiple simultaneous installs.
747 if ( get_option( 'woocommerce_setup_background_installing_' . $plugin_id ) ) {
748 return;
749 }
750
751 $plugin_file = isset( $plugin_info['file'] ) ? $plugin_info['file'] : $plugin_info['repo-slug'] . '.php';
752 if ( is_plugin_active( $plugin_info['repo-slug'] . '/' . $plugin_file ) ) {
753 return;
754 }
755
756 if ( empty( $this->deferred_actions ) ) {
757 add_action( 'shutdown', array( $this, 'run_deferred_actions' ) );
758 }
759
760 array_push(
761 $this->deferred_actions,
762 array(
763 'func' => array( 'WC_Install', 'background_installer' ),
764 'args' => array( $plugin_id, $plugin_info ),
765 )
766 );
767
768 // Set the background installation flag for this plugin.
769 update_option( 'woocommerce_setup_background_installing_' . $plugin_id, true );
770 }
771
772
773 /**
774 * Helper method to queue the background install of a theme.
775 *
776 * @param string $theme_id Theme id used for background install.
777 *
778 * @deprecated 4.6.0
779 * @return void
780 */
781 protected function install_theme( $theme_id ) {
782 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
783 if ( empty( $this->deferred_actions ) ) {
784 add_action( 'shutdown', array( $this, 'run_deferred_actions' ) );
785 }
786 array_push(
787 $this->deferred_actions,
788 array(
789 'func' => array( 'WC_Install', 'theme_background_installer' ),
790 'args' => array( $theme_id ),
791 )
792 );
793 }
794
795 /**
796 * Helper method to install Jetpack.
797 *
798 * @deprecated 4.6.0
799 * @return void
800 */
801 protected function install_jetpack() {
802 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
803 $this->install_plugin(
804 'jetpack',
805 array(
806 'name' => __( 'Jetpack', 'woocommerce' ),
807 'repo-slug' => 'jetpack',
808 )
809 );
810 }
811
812 /**
813 * Helper method to install WooCommerce Services and its Jetpack dependency.
814 *
815 * @deprecated 4.6.0
816 * @return void
817 */
818 protected function install_woocommerce_services() {
819 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
820 $this->install_jetpack();
821 $this->install_plugin(
822 'woocommerce-services',
823 array(
824 'name' => __( 'WooCommerce Services', 'woocommerce' ),
825 'repo-slug' => 'woocommerce-services',
826 )
827 );
828 }
829
830 /**
831 * Retrieve info for missing WooCommerce Services and/or Jetpack plugin.
832 *
833 * @deprecated 4.6.0
834 * @return array
835 */
836 protected function get_wcs_requisite_plugins() {
837 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
838 $plugins = array();
839 if ( ! is_plugin_active( 'woocommerce-services/woocommerce-services.php' ) && ! get_option( 'woocommerce_setup_background_installing_woocommerce-services' ) ) {
840 $plugins[] = array(
841 'name' => __( 'WooCommerce Services', 'woocommerce' ),
842 'slug' => 'woocommerce-services',
843 );
844 }
845 if ( ! is_plugin_active( 'jetpack/jetpack.php' ) && ! get_option( 'woocommerce_setup_background_installing_jetpack' ) ) {
846 $plugins[] = array(
847 'name' => __( 'Jetpack', 'woocommerce' ),
848 'slug' => 'jetpack',
849 );
850 }
851 return $plugins;
852 }
853
854 /**
855 * Plugin install info message markup with heading.
856 *
857 * @deprecated 4.6.0
858 * @return void
859 */
860 public function plugin_install_info() {
861 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
862 ?>
863 <span class="plugin-install-info">
864 <span class="plugin-install-info-label"><?php esc_html_e( 'The following plugins will be installed and activated for you:', 'woocommerce' ); ?></span>
865 <span class="plugin-install-info-list"></span>
866 </span>
867 <?php
868 }
869
870 /**
871 * Get shipping methods based on country code.
872 *
873 * @param string $country_code Country code.
874 * @param string $currency_code Currency code.
875 *
876 * @deprecated 4.6.0
877 * @return array
878 */
879 protected function get_wizard_shipping_methods( $country_code, $currency_code ) {
880 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
881 $shipping_methods = array(
882 'flat_rate' => array(
883 'name' => __( 'Flat Rate', 'woocommerce' ),
884 'description' => __( 'Set a fixed price to cover shipping costs.', 'woocommerce' ),
885 'settings' => array(
886 'cost' => array(
887 'type' => 'text',
888 'default_value' => __( 'Cost', 'woocommerce' ),
889 'description' => __( 'What would you like to charge for flat rate shipping?', 'woocommerce' ),
890 'required' => true,
891 ),
892 ),
893 ),
894 'free_shipping' => array(
895 'name' => __( 'Free Shipping', 'woocommerce' ),
896 'description' => __( "Don't charge for shipping.", 'woocommerce' ),
897 ),
898 );
899
900 return $shipping_methods;
901 }
902
903 /**
904 * Render the available shipping methods for a given country code.
905 *
906 * @param string $country_code Country code.
907 * @param string $currency_code Currency code.
908 * @param string $input_prefix Input prefix.
909 *
910 * @deprecated 4.6.0
911 * @return void
912 */
913 protected function shipping_method_selection_form( $country_code, $currency_code, $input_prefix ) {
914 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
915 $selected = 'flat_rate';
916 $shipping_methods = $this->get_wizard_shipping_methods( $country_code, $currency_code );
917 ?>
918 <div class="wc-wizard-shipping-method-select">
919 <div class="wc-wizard-shipping-method-dropdown">
920 <select
921 id="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
922 name="<?php echo esc_attr( "{$input_prefix}[method]" ); ?>"
923 class="method wc-enhanced-select"
924 data-plugins="<?php echo wc_esc_json( wp_json_encode( $this->get_wcs_requisite_plugins() ) ); ?>"
925 >
926 <?php foreach ( $shipping_methods as $method_id => $method ) : ?>
927 <option value="<?php echo esc_attr( $method_id ); ?>" <?php selected( $selected, $method_id ); ?>><?php echo esc_html( $method['name'] ); ?></option>
928 <?php endforeach; ?>
929 </select>
930 </div>
931 <div class="shipping-method-descriptions">
932 <?php foreach ( $shipping_methods as $method_id => $method ) : ?>
933 <p class="shipping-method-description <?php echo esc_attr( $method_id ); ?> <?php echo $method_id !== $selected ? 'hide' : ''; ?>">
934 <?php echo esc_html( $method['description'] ); ?>
935 </p>
936 <?php endforeach; ?>
937 </div>
938 </div>
939
940 <div class="shipping-method-settings">
941 <?php foreach ( $shipping_methods as $method_id => $method ) : ?>
942 <?php
943 if ( empty( $method['settings'] ) ) {
944 continue;
945 }
946 ?>
947 <div class="shipping-method-setting <?php echo esc_attr( $method_id ); ?> <?php echo $method_id !== $selected ? 'hide' : ''; ?>">
948 <?php foreach ( $method['settings'] as $setting_id => $setting ) : ?>
949 <?php $method_setting_id = "{$input_prefix}[{$method_id}][{$setting_id}]"; ?>
950 <input
951 type="<?php echo esc_attr( $setting['type'] ); ?>"
952 placeholder="<?php echo esc_attr( $setting['default_value'] ); ?>"
953 id="<?php echo esc_attr( $method_setting_id ); ?>"
954 name="<?php echo esc_attr( $method_setting_id ); ?>"
955 class="<?php echo esc_attr( $setting['required'] ? 'shipping-method-required-field' : '' ); ?>"
956 <?php echo ( $method_id === $selected && $setting['required'] ) ? 'required' : ''; ?>
957 />
958 <p class="description">
959 <?php echo esc_html( $setting['description'] ); ?>
960 </p>
961 <?php endforeach; ?>
962 </div>
963 <?php endforeach; ?>
964 </div>
965 <?php
966 }
967
968 /**
969 * Render a product weight unit dropdown.
970 *
971 * @deprecated 4.6.0
972 * @return string|false
973 */
974 protected function get_product_weight_selection() {
975 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
976 $weight_unit = get_option( 'woocommerce_weight_unit' );
977 ob_start();
978 ?>
979 <span class="wc-setup-shipping-unit">
980 <select id="weight_unit" name="weight_unit" class="wc-enhanced-select">
981 <option value="kg" <?php selected( $weight_unit, 'kg' ); ?>><?php esc_html_e( 'Kilograms', 'woocommerce' ); ?></option>
982 <option value="g" <?php selected( $weight_unit, 'g' ); ?>><?php esc_html_e( 'Grams', 'woocommerce' ); ?></option>
983 <option value="lbs" <?php selected( $weight_unit, 'lbs' ); ?>><?php esc_html_e( 'Pounds', 'woocommerce' ); ?></option>
984 <option value="oz" <?php selected( $weight_unit, 'oz' ); ?>><?php esc_html_e( 'Ounces', 'woocommerce' ); ?></option>
985 </select>
986 </span>
987 <?php
988
989 return ob_get_clean();
990 }
991
992 /**
993 * Render a product dimension unit dropdown.
994 *
995 * @deprecated 4.6.0
996 * @return string|false
997 */
998 protected function get_product_dimension_selection() {
999 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1000 $dimension_unit = get_option( 'woocommerce_dimension_unit' );
1001 ob_start();
1002 ?>
1003 <span class="wc-setup-shipping-unit">
1004 <select id="dimension_unit" name="dimension_unit" class="wc-enhanced-select">
1005 <option value="m" <?php selected( $dimension_unit, 'm' ); ?>><?php esc_html_e( 'Meters', 'woocommerce' ); ?></option>
1006 <option value="cm" <?php selected( $dimension_unit, 'cm' ); ?>><?php esc_html_e( 'Centimeters', 'woocommerce' ); ?></option>
1007 <option value="mm" <?php selected( $dimension_unit, 'mm' ); ?>><?php esc_html_e( 'Millimeters', 'woocommerce' ); ?></option>
1008 <option value="in" <?php selected( $dimension_unit, 'in' ); ?>><?php esc_html_e( 'Inches', 'woocommerce' ); ?></option>
1009 <option value="yd" <?php selected( $dimension_unit, 'yd' ); ?>><?php esc_html_e( 'Yards', 'woocommerce' ); ?></option>
1010 </select>
1011 </span>
1012 <?php
1013
1014 return ob_get_clean();
1015 }
1016
1017 /**
1018 * Shipping.
1019 *
1020 * @deprecated 4.6.0
1021 * @return void
1022 */
1023 public function wc_setup_shipping() {
1024 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1025 $country_code = WC()->countries->get_base_country();
1026 $country_name = WC()->countries->countries[ $country_code ];
1027 $prefixed_country_name = WC()->countries->estimated_for_prefix( $country_code ) . $country_name;
1028 $currency_code = get_woocommerce_currency();
1029 $existing_zones = WC_Shipping_Zones::get_zones();
1030 $intro_text = '';
1031
1032 if ( empty( $existing_zones ) ) {
1033 $intro_text = sprintf(
1034 /* translators: %s: country name including the 'the' prefix if needed */
1035 __( "We've created two Shipping Zones - for %s and for the rest of the world. Below you can set Flat Rate shipping costs for these Zones or offer Free Shipping.", 'woocommerce' ),
1036 $prefixed_country_name
1037 );
1038 }
1039
1040 $is_wcs_labels_supported = $this->is_wcs_shipping_labels_supported_country( $country_code );
1041 $is_shipstation_supported = $this->is_shipstation_supported_country( $country_code );
1042
1043 ?>
1044 <h1><?php esc_html_e( 'Shipping', 'woocommerce' ); ?></h1>
1045 <?php if ( $intro_text ) : ?>
1046 <p><?php echo wp_kses_post( $intro_text ); ?></p>
1047 <?php endif; ?>
1048 <form method="post">
1049 <?php if ( $is_wcs_labels_supported || $is_shipstation_supported ) : ?>
1050 <ul class="wc-setup-shipping-recommended">
1051 <?php
1052 if ( $is_wcs_labels_supported ) :
1053 $this->display_recommended_item(
1054 array(
1055 'type' => 'woocommerce_services',
1056 'title' => __( 'Did you know you can print shipping labels at home?', 'woocommerce' ),
1057 'description' => __( 'Use WooCommerce Shipping (powered by WooCommerce Services & Jetpack) to save time at the post office by printing your shipping labels at home.', 'woocommerce' ),
1058 'img_url' => WC()->plugin_url() . '/assets/images/obw-woocommerce-services-icon.png',
1059 'img_alt' => __( 'WooCommerce Services icon', 'woocommerce' ),
1060 'plugins' => $this->get_wcs_requisite_plugins(),
1061 )
1062 );
1063 elseif ( $is_shipstation_supported ) :
1064 $this->display_recommended_item(
1065 array(
1066 'type' => 'shipstation',
1067 'title' => __( 'Did you know you can print shipping labels at home?', 'woocommerce' ),
1068 'description' => __( 'We recommend using ShipStation to save time at the post office by printing your shipping labels at home. Try ShipStation free for 30 days.', 'woocommerce' ),
1069 'img_url' => WC()->plugin_url() . '/assets/images/obw-shipstation-icon.png',
1070 'img_alt' => __( 'ShipStation icon', 'woocommerce' ),
1071 'plugins' => array(
1072 array(
1073 'name' => __( 'ShipStation', 'woocommerce' ),
1074 'slug' => 'woocommerce-shipstation-integration',
1075 ),
1076 ),
1077 )
1078 );
1079 endif;
1080 ?>
1081 </ul>
1082 <?php endif; ?>
1083
1084 <?php if ( empty( $existing_zones ) ) : ?>
1085 <ul class="wc-wizard-services shipping">
1086 <li class="wc-wizard-service-item">
1087 <div class="wc-wizard-service-name">
1088 <p><?php esc_html_e( 'Shipping Zone', 'woocommerce' ); ?></p>
1089 </div>
1090 <div class="wc-wizard-service-description">
1091 <p><?php esc_html_e( 'Shipping Method', 'woocommerce' ); ?></p>
1092 </div>
1093 </li>
1094 <li class="wc-wizard-service-item">
1095 <div class="wc-wizard-service-name">
1096 <p><?php echo esc_html( $country_name ); ?></p>
1097 </div>
1098 <div class="wc-wizard-service-description">
1099 <?php $this->shipping_method_selection_form( $country_code, $currency_code, 'shipping_zones[domestic]' ); ?>
1100 </div>
1101 <div class="wc-wizard-service-enable">
1102 <span class="wc-wizard-service-toggle">
1103 <input id="shipping_zones[domestic][enabled]" type="checkbox" name="shipping_zones[domestic][enabled]" value="yes" checked="checked" class="wc-wizard-shipping-method-enable" data-plugins="true" />
1104 <label for="shipping_zones[domestic][enabled]">
1105 </span>
1106 </div>
1107 </li>
1108 <li class="wc-wizard-service-item">
1109 <div class="wc-wizard-service-name">
1110 <p><?php esc_html_e( 'Locations not covered by your other zones', 'woocommerce' ); ?></p>
1111 </div>
1112 <div class="wc-wizard-service-description">
1113 <?php $this->shipping_method_selection_form( $country_code, $currency_code, 'shipping_zones[intl]' ); ?>
1114 </div>
1115 <div class="wc-wizard-service-enable">
1116 <span class="wc-wizard-service-toggle">
1117 <input id="shipping_zones[intl][enabled]" type="checkbox" name="shipping_zones[intl][enabled]" value="yes" checked="checked" class="wc-wizard-shipping-method-enable" data-plugins="true" />
1118 <label for="shipping_zones[intl][enabled]">
1119 </span>
1120 </div>
1121 </li>
1122 <li class="wc-wizard-service-info">
1123 <p>
1124 <?php
1125 printf(
1126 wp_kses(
1127 /* translators: %1$s: live rates tooltip text, %2$s: shipping extensions URL */
1128 __( 'If you\'d like to offer <span class="help_tip" data-tip="%1$s">live rates</span> from a specific carrier (e.g. UPS) you can find a variety of extensions available for WooCommerce <a href="%2$s" target="_blank">here</a>.', 'woocommerce' ),
1129 array(
1130 'span' => array(
1131 'class' => array(),
1132 'data-tip' => array(),
1133 ),
1134 'a' => array(
1135 'href' => array(),
1136 'target' => array(),
1137 ),
1138 )
1139 ),
1140 esc_attr__( 'A live rate is the exact cost to ship an order, quoted directly from the shipping carrier.', 'woocommerce' ),
1141 'https://woocommerce.com/product-category/woocommerce-extensions/shipping-methods/shipping-carriers/'
1142 );
1143 ?>
1144 </p>
1145 </li>
1146 </ul>
1147 <?php endif; ?>
1148
1149 <div class="wc-setup-shipping-units">
1150 <p>
1151 <?php
1152 echo wp_kses(
1153 sprintf(
1154 /* translators: %1$s: weight unit dropdown, %2$s: dimension unit dropdown */
1155 esc_html__( 'We\'ll use %1$s for product weight and %2$s for product dimensions.', 'woocommerce' ),
1156 $this->get_product_weight_selection(),
1157 $this->get_product_dimension_selection()
1158 ),
1159 array(
1160 'span' => array(
1161 'class' => array(),
1162 ),
1163 'select' => array(
1164 'id' => array(),
1165 'name' => array(),
1166 'class' => array(),
1167 ),
1168 'option' => array(
1169 'value' => array(),
1170 'selected' => array(),
1171 ),
1172 )
1173 );
1174 ?>
1175 </p>
1176 </div>
1177
1178 <p class="wc-setup-actions step">
1179 <?php $this->plugin_install_info(); ?>
1180 <button class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Continue', 'woocommerce' ); ?></button>
1181 <?php wp_nonce_field( 'wc-setup' ); ?>
1182 </p>
1183 </form>
1184 <?php
1185 }
1186
1187 /**
1188 * Save shipping options.
1189 *
1190 * @deprecated 4.6.0
1191 * @return void
1192 */
1193 public function wc_setup_shipping_save() {
1194 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1195 }
1196
1197 /**
1198 * Is Stripe country supported
1199 * https://stripe.com/global .
1200 *
1201 * @param string $country_code Country code.
1202 *
1203 * @deprecated 4.6.0
1204 * @return bool
1205 */
1206 protected function is_stripe_supported_country( $country_code ) {
1207 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1208 $stripe_supported_countries = array(
1209 'AU',
1210 'AT',
1211 'BE',
1212 'CA',
1213 'DK',
1214 'FI',
1215 'FR',
1216 'DE',
1217 'HK',
1218 'IE',
1219 'JP',
1220 'LU',
1221 'NL',
1222 'NZ',
1223 'NO',
1224 'SG',
1225 'ES',
1226 'SE',
1227 'CH',
1228 'GB',
1229 'US',
1230 );
1231
1232 return in_array( $country_code, $stripe_supported_countries, true );
1233 }
1234
1235 /**
1236 * Is PayPal currency supported.
1237 *
1238 * @param string $currency Currency code.
1239 * @return boolean
1240 *
1241 * @deprecated 4.6.0
1242 */
1243 protected function is_paypal_supported_currency( $currency ) {
1244 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1245 $supported_currencies = array(
1246 'AUD',
1247 'BRL',
1248 'CAD',
1249 'MXN',
1250 'NZD',
1251 'HKD',
1252 'SGD',
1253 'USD',
1254 'EUR',
1255 'JPY',
1256 'TRY',
1257 'NOK',
1258 'CZK',
1259 'DKK',
1260 'HUF',
1261 'ILS',
1262 'MYR',
1263 'PHP',
1264 'PLN',
1265 'SEK',
1266 'CHF',
1267 'TWD',
1268 'THB',
1269 'GBP',
1270 'RMB',
1271 'RUB',
1272 'INR',
1273 );
1274 return in_array( $currency, $supported_currencies, true );
1275 }
1276
1277 /**
1278 * Is Klarna Checkout country supported.
1279 *
1280 * @param string $country_code Country code.
1281 *
1282 * @deprecated 4.6.0
1283 * @return bool
1284 */
1285 protected function is_klarna_checkout_supported_country( $country_code ) {
1286 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1287 $supported_countries = array(
1288 'SE', // Sweden.
1289 'FI', // Finland.
1290 'NO', // Norway.
1291 'NL', // Netherlands.
1292 );
1293 return in_array( $country_code, $supported_countries, true );
1294 }
1295
1296 /**
1297 * Is Klarna Payments country supported.
1298 *
1299 * @param string $country_code Country code.
1300 *
1301 * @deprecated 4.6.0
1302 * @return bool
1303 */
1304 protected function is_klarna_payments_supported_country( $country_code ) {
1305 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1306 $supported_countries = array(
1307 'DK', // Denmark.
1308 'DE', // Germany.
1309 'AT', // Austria.
1310 );
1311 return in_array( $country_code, $supported_countries, true );
1312 }
1313
1314 /**
1315 * Is Square country supported
1316 *
1317 * @param string $country_code Country code.
1318 *
1319 * @deprecated 4.6.0
1320 * @return bool
1321 */
1322 protected function is_square_supported_country( $country_code ) {
1323 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1324 $square_supported_countries = array(
1325 'US',
1326 'CA',
1327 'JP',
1328 'GB',
1329 'AU',
1330 );
1331 return in_array( $country_code, $square_supported_countries, true );
1332 }
1333
1334 /**
1335 * Is eWAY Payments country supported
1336 *
1337 * @param string $country_code Country code.
1338 *
1339 * @deprecated 4.6.0
1340 * @return bool
1341 */
1342 protected function is_eway_payments_supported_country( $country_code ) {
1343 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1344 $supported_countries = array(
1345 'AU', // Australia.
1346 'NZ', // New Zealand.
1347 );
1348 return in_array( $country_code, $supported_countries, true );
1349 }
1350
1351 /**
1352 * Is ShipStation country supported
1353 *
1354 * @param string $country_code Country code.
1355 *
1356 * @deprecated 4.6.0
1357 * @return bool
1358 */
1359 protected function is_shipstation_supported_country( $country_code ) {
1360 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1361 $supported_countries = array(
1362 'AU', // Australia.
1363 'CA', // Canada.
1364 'GB', // United Kingdom.
1365 );
1366 return in_array( $country_code, $supported_countries, true );
1367 }
1368
1369 /**
1370 * Is WooCommerce Services shipping label country supported
1371 *
1372 * @param string $country_code Country code.
1373 *
1374 * @deprecated 4.6.0
1375 * @return bool
1376 */
1377 protected function is_wcs_shipping_labels_supported_country( $country_code ) {
1378 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1379 $supported_countries = array(
1380 'US', // United States.
1381 );
1382 return in_array( $country_code, $supported_countries, true );
1383 }
1384
1385 /**
1386 * Helper method to retrieve the current user's email address.
1387 *
1388 * @deprecated 4.6.0
1389 * @return string Email address
1390 */
1391 protected function get_current_user_email() {
1392 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1393 $current_user = wp_get_current_user();
1394 $user_email = $current_user->user_email;
1395
1396 return $user_email;
1397 }
1398
1399 /**
1400 * Array of all possible "in cart" gateways that can be offered.
1401 *
1402 * @deprecated 4.6.0
1403 * @return array
1404 */
1405 protected function get_wizard_available_in_cart_payment_gateways() {
1406 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1407 $user_email = $this->get_current_user_email();
1408
1409 $stripe_description = '<p>' . sprintf(
1410 /* translators: %s: URL */
1411 __( 'Accept debit and credit cards in 135+ currencies, methods such as Alipay, and one-touch checkout with Apple Pay. <a href="%s" target="_blank">Learn more</a>.', 'woocommerce' ),
1412 'https://woocommerce.com/products/stripe/'
1413 ) . '</p>';
1414 $paypal_checkout_description = '<p>' . sprintf(
1415 /* translators: %s: URL */
1416 __( 'Safe and secure payments using credit cards or your customer\'s PayPal account. <a href="%s" target="_blank">Learn more</a>.', 'woocommerce' ),
1417 'https://woocommerce.com/products/woocommerce-gateway-paypal-checkout/'
1418 ) . '</p>';
1419 $klarna_checkout_description = '<p>' . sprintf(
1420 /* translators: %s: URL */
1421 __( 'Full checkout experience with pay now, pay later and slice it. No credit card numbers, no passwords, no worries. <a href="%s" target="_blank">Learn more about Klarna</a>.', 'woocommerce' ),
1422 'https://woocommerce.com/products/klarna-checkout/'
1423 ) . '</p>';
1424 $klarna_payments_description = '<p>' . sprintf(
1425 /* translators: %s: URL */
1426 __( 'Choose the payment that you want, pay now, pay later or slice it. No credit card numbers, no passwords, no worries. <a href="%s" target="_blank">Learn more about Klarna</a>.', 'woocommerce' ),
1427 'https://woocommerce.com/products/klarna-payments/ '
1428 ) . '</p>';
1429 $square_description = '<p>' . sprintf(
1430 /* translators: %s: URL */
1431 __( 'Securely accept credit and debit cards with one low rate, no surprise fees (custom rates available). Sell online and in store and track sales and inventory in one place. <a href="%s" target="_blank">Learn more about Square</a>.', 'woocommerce' ),
1432 'https://woocommerce.com/products/square/'
1433 ) . '</p>';
1434
1435 return array(
1436 'stripe' => array(
1437 'name' => __( 'WooCommerce Stripe Gateway', 'woocommerce' ),
1438 'image' => WC()->plugin_url() . '/assets/images/stripe.png',
1439 'description' => $stripe_description,
1440 'class' => 'checked stripe-logo',
1441 'repo-slug' => 'woocommerce-gateway-stripe',
1442 'settings' => array(
1443 'create_account' => array(
1444 'label' => __( 'Set up Stripe for me using this email:', 'woocommerce' ),
1445 'type' => 'checkbox',
1446 'value' => 'yes',
1447 'default' => 'yes',
1448 'placeholder' => '',
1449 'required' => false,
1450 'plugins' => $this->get_wcs_requisite_plugins(),
1451 ),
1452 'email' => array(
1453 'label' => __( 'Stripe email address:', 'woocommerce' ),
1454 'type' => 'email',
1455 'value' => $user_email,
1456 'placeholder' => __( 'Stripe email address', 'woocommerce' ),
1457 'required' => true,
1458 ),
1459 ),
1460 ),
1461 'ppec_paypal' => array(
1462 'name' => __( 'WooCommerce PayPal Checkout Gateway', 'woocommerce' ),
1463 'image' => WC()->plugin_url() . '/assets/images/paypal.png',
1464 'description' => $paypal_checkout_description,
1465 'enabled' => false,
1466 'class' => 'checked paypal-logo',
1467 'repo-slug' => 'woocommerce-gateway-paypal-express-checkout',
1468 'settings' => array(
1469 'reroute_requests' => array(
1470 'label' => __( 'Set up PayPal for me using this email:', 'woocommerce' ),
1471 'type' => 'checkbox',
1472 'value' => 'yes',
1473 'default' => 'yes',
1474 'placeholder' => '',
1475 'required' => false,
1476 'plugins' => $this->get_wcs_requisite_plugins(),
1477 ),
1478 'email' => array(
1479 'label' => __( 'Direct payments to email address:', 'woocommerce' ),
1480 'type' => 'email',
1481 'value' => $user_email,
1482 'placeholder' => __( 'Email address to receive payments', 'woocommerce' ),
1483 'required' => true,
1484 ),
1485 ),
1486 ),
1487 WC_Gateway_Paypal::ID => array(
1488 'name' => __( 'PayPal Standard', 'woocommerce' ),
1489 'description' => __( 'Accept payments via PayPal using account balance or credit card.', 'woocommerce' ),
1490 'image' => '',
1491 'settings' => array(
1492 'email' => array(
1493 'label' => __( 'PayPal email address:', 'woocommerce' ),
1494 'type' => 'email',
1495 'value' => $user_email,
1496 'placeholder' => __( 'PayPal email address', 'woocommerce' ),
1497 'required' => true,
1498 ),
1499 ),
1500 ),
1501 'klarna_checkout' => array(
1502 'name' => __( 'Klarna Checkout for WooCommerce', 'woocommerce' ),
1503 'description' => $klarna_checkout_description,
1504 'image' => WC()->plugin_url() . '/assets/images/klarna-black.png',
1505 'enabled' => true,
1506 'class' => 'klarna-logo',
1507 'repo-slug' => 'klarna-checkout-for-woocommerce',
1508 ),
1509 'klarna_payments' => array(
1510 'name' => __( 'Klarna Payments for WooCommerce', 'woocommerce' ),
1511 'description' => $klarna_payments_description,
1512 'image' => WC()->plugin_url() . '/assets/images/klarna-black.png',
1513 'enabled' => true,
1514 'class' => 'klarna-logo',
1515 'repo-slug' => 'klarna-payments-for-woocommerce',
1516 ),
1517 'square' => array(
1518 'name' => __( 'WooCommerce Square', 'woocommerce' ),
1519 'description' => $square_description,
1520 'image' => WC()->plugin_url() . '/assets/images/square-black.png',
1521 'class' => 'square-logo',
1522 'enabled' => false,
1523 'repo-slug' => 'woocommerce-square',
1524 ),
1525 'eway' => array(
1526 'name' => __( 'WooCommerce eWAY Gateway', 'woocommerce' ),
1527 'description' => __( 'The eWAY extension for WooCommerce allows you to take credit card payments directly on your store without redirecting your customers to a third party site to make payment.', 'woocommerce' ),
1528 'image' => WC()->plugin_url() . '/assets/images/eway-logo.jpg',
1529 'enabled' => false,
1530 'class' => 'eway-logo',
1531 'repo-slug' => 'woocommerce-gateway-eway',
1532 ),
1533 'payfast' => array(
1534 'name' => __( 'WooCommerce PayFast Gateway', 'woocommerce' ),
1535 'description' => __( 'The PayFast extension for WooCommerce enables you to accept payments by Credit Card and EFT via one of South Africa’s most popular payment gateways. No setup fees or monthly subscription costs.', 'woocommerce' ),
1536 'image' => WC()->plugin_url() . '/assets/images/payfast.png',
1537 'class' => 'payfast-logo',
1538 'enabled' => false,
1539 'repo-slug' => 'woocommerce-payfast-gateway',
1540 'file' => 'gateway-payfast.php',
1541 ),
1542 );
1543 }
1544
1545 /**
1546 * Simple array of "in cart" gateways to show in wizard.
1547 *
1548 * @deprecated 4.6.0
1549 * @return array
1550 */
1551 public function get_wizard_in_cart_payment_gateways() {
1552 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1553 $gateways = $this->get_wizard_available_in_cart_payment_gateways();
1554 $country = WC()->countries->get_base_country();
1555 $currency = get_woocommerce_currency();
1556
1557 $can_stripe = $this->is_stripe_supported_country( $country );
1558 $can_eway = $this->is_eway_payments_supported_country( $country );
1559 $can_payfast = ( 'ZA' === $country ); // South Africa.
1560 $can_paypal = $this->is_paypal_supported_currency( $currency );
1561
1562 if ( ! current_user_can( 'install_plugins' ) ) {
1563 return $can_paypal ? array( WC_Gateway_Paypal::ID => $gateways[ WC_Gateway_Paypal::ID ] ) : array();
1564 }
1565
1566 $klarna_or_square = false;
1567
1568 if ( $this->is_klarna_checkout_supported_country( $country ) ) {
1569 $klarna_or_square = 'klarna_checkout';
1570 } elseif ( $this->is_klarna_payments_supported_country( $country ) ) {
1571 $klarna_or_square = 'klarna_payments';
1572 } elseif ( $this->is_square_supported_country( $country ) && get_option( 'woocommerce_sell_in_person' ) ) {
1573 $klarna_or_square = 'square';
1574 }
1575
1576 $offered_gateways = array();
1577
1578 if ( $can_stripe ) {
1579 $gateways['stripe']['enabled'] = true;
1580 $gateways['stripe']['featured'] = true;
1581 $offered_gateways += array( 'stripe' => $gateways['stripe'] );
1582 } elseif ( $can_paypal ) {
1583 $gateways['ppec_paypal']['enabled'] = true;
1584 }
1585
1586 if ( $klarna_or_square ) {
1587 if ( in_array( $klarna_or_square, array( 'klarna_checkout', 'klarna_payments' ), true ) ) {
1588 $gateways[ $klarna_or_square ]['enabled'] = true;
1589 $gateways[ $klarna_or_square ]['featured'] = false;
1590 $offered_gateways += array(
1591 $klarna_or_square => $gateways[ $klarna_or_square ],
1592 );
1593 } else {
1594 $offered_gateways += array(
1595 $klarna_or_square => $gateways[ $klarna_or_square ],
1596 );
1597 }
1598 }
1599
1600 if ( $can_paypal ) {
1601 $offered_gateways += array( 'ppec_paypal' => $gateways['ppec_paypal'] );
1602 }
1603
1604 if ( $can_eway ) {
1605 $offered_gateways += array( 'eway' => $gateways['eway'] );
1606 }
1607
1608 if ( $can_payfast ) {
1609 $offered_gateways += array( 'payfast' => $gateways['payfast'] );
1610 }
1611
1612 return $offered_gateways;
1613 }
1614
1615 /**
1616 * Simple array of "manual" gateways to show in wizard.
1617 *
1618 * @deprecated 4.6.0
1619 * @return array
1620 */
1621 public function get_wizard_manual_payment_gateways() {
1622 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1623 $gateways = array(
1624 WC_Gateway_Cheque::ID => array(
1625 'name' => _x( 'Check payments', 'Check payment method', 'woocommerce' ),
1626 'description' => __( 'A simple offline gateway that lets you accept a check as method of payment.', 'woocommerce' ),
1627 'image' => '',
1628 'class' => '',
1629 ),
1630 WC_Gateway_BACS::ID => array(
1631 'name' => __( 'Bank transfer (BACS) payments', 'woocommerce' ),
1632 'description' => __( 'A simple offline gateway that lets you accept BACS payment.', 'woocommerce' ),
1633 'image' => '',
1634 'class' => '',
1635 ),
1636 WC_Gateway_COD::ID => array(
1637 'name' => __( 'Cash on delivery', 'woocommerce' ),
1638 'description' => __( 'A simple offline gateway that lets you accept cash on delivery.', 'woocommerce' ),
1639 'image' => '',
1640 'class' => '',
1641 ),
1642 );
1643
1644 return $gateways;
1645 }
1646
1647 /**
1648 * Display service item in list.
1649 *
1650 * @param int $item_id Item ID.
1651 * @param array $item_info Item info array.
1652 *
1653 * @deprecated 4.6.0
1654 * @return void
1655 */
1656 public function display_service_item( $item_id, $item_info ) {
1657 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1658 $item_class = 'wc-wizard-service-item';
1659 if ( isset( $item_info['class'] ) ) {
1660 $item_class .= ' ' . $item_info['class'];
1661 }
1662
1663 $previously_saved_settings = get_option( 'woocommerce_' . $item_id . '_settings' );
1664
1665 // Show the user-saved state if it was previously saved.
1666 // Otherwise, rely on the item info.
1667 if ( is_array( $previously_saved_settings ) ) {
1668 $should_enable_toggle = ( isset( $previously_saved_settings['enabled'] ) && 'yes' === $previously_saved_settings['enabled'] ) ? true : ( isset( $item_info['enabled'] ) && $item_info['enabled'] );
1669 } else {
1670 $should_enable_toggle = isset( $item_info['enabled'] ) && $item_info['enabled'];
1671 }
1672
1673 $plugins = null;
1674 if ( isset( $item_info['repo-slug'] ) ) {
1675 $plugin = array(
1676 'slug' => $item_info['repo-slug'],
1677 'name' => $item_info['name'],
1678 );
1679 $plugins = array( $plugin );
1680 }
1681
1682 ?>
1683 <li class="<?php echo esc_attr( $item_class ); ?>">
1684 <div class="wc-wizard-service-name">
1685 <?php if ( ! empty( $item_info['image'] ) ) : ?>
1686 <img src="<?php echo esc_attr( $item_info['image'] ); ?>" alt="<?php echo esc_attr( $item_info['name'] ); ?>" />
1687 <?php else : ?>
1688 <p><?php echo esc_html( $item_info['name'] ); ?></p>
1689 <?php endif; ?>
1690 </div>
1691 <div class="wc-wizard-service-enable">
1692 <span class="wc-wizard-service-toggle <?php echo esc_attr( $should_enable_toggle ? '' : 'disabled' ); ?>" tabindex="0">
1693 <input
1694 id="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>"
1695 type="checkbox"
1696 name="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>-enabled"
1697 value="yes" <?php checked( $should_enable_toggle ); ?>
1698 data-plugins="<?php echo wc_esc_json( wp_json_encode( $plugins ) ); ?>"
1699 />
1700 <label for="wc-wizard-service-<?php echo esc_attr( $item_id ); ?>">
1701 </span>
1702 </div>
1703 <div class="wc-wizard-service-description">
1704 <?php echo wp_kses_post( wpautop( $item_info['description'] ) ); ?>
1705 <?php if ( ! empty( $item_info['settings'] ) ) : ?>
1706 <div class="wc-wizard-service-settings <?php echo $should_enable_toggle ? '' : 'hide'; ?>">
1707 <?php foreach ( $item_info['settings'] as $setting_id => $setting ) : ?>
1708 <?php
1709 $is_checkbox = 'checkbox' === $setting['type'];
1710
1711 if ( $is_checkbox ) {
1712 $checked = false;
1713 if ( isset( $previously_saved_settings[ $setting_id ] ) ) {
1714 $checked = 'yes' === $previously_saved_settings[ $setting_id ];
1715 } elseif ( false === $previously_saved_settings && isset( $setting['default'] ) ) {
1716 $checked = 'yes' === $setting['default'];
1717 }
1718 }
1719 if ( 'email' === $setting['type'] ) {
1720 $value = empty( $previously_saved_settings[ $setting_id ] )
1721 ? $setting['value']
1722 : $previously_saved_settings[ $setting_id ];
1723 }
1724 ?>
1725 <?php $input_id = $item_id . '_' . $setting_id; ?>
1726 <div class="<?php echo esc_attr( 'wc-wizard-service-setting-' . $input_id ); ?>">
1727 <label
1728 for="<?php echo esc_attr( $input_id ); ?>"
1729 class="<?php echo esc_attr( $input_id ); ?>"
1730 >
1731 <?php echo esc_html( $setting['label'] ); ?>
1732 </label>
1733 <input
1734 type="<?php echo esc_attr( $setting['type'] ); ?>"
1735 id="<?php echo esc_attr( $input_id ); ?>"
1736 class="<?php echo esc_attr( 'payment-' . $setting['type'] . '-input' ); ?>"
1737 name="<?php echo esc_attr( $input_id ); ?>"
1738 value="<?php echo esc_attr( isset( $value ) ? $value : $setting['value'] ); ?>"
1739 placeholder="<?php echo esc_attr( $setting['placeholder'] ); ?>"
1740 <?php echo ( $setting['required'] ) ? 'required' : ''; ?>
1741 <?php echo $is_checkbox ? checked( isset( $checked ) && $checked, true, false ) : ''; ?>
1742 data-plugins="<?php echo wc_esc_json( wp_json_encode( isset( $setting['plugins'] ) ? $setting['plugins'] : null ) ); ?>"
1743 />
1744 <?php if ( ! empty( $setting['description'] ) ) : ?>
1745 <span class="wc-wizard-service-settings-description"><?php echo esc_html( $setting['description'] ); ?></span>
1746 <?php endif; ?>
1747 </div>
1748 <?php endforeach; ?>
1749 </div>
1750 <?php endif; ?>
1751 </div>
1752 </li>
1753 <?php
1754 }
1755
1756 /**
1757 * Is it a featured service?
1758 *
1759 * @param array $service Service info array.
1760 *
1761 * @deprecated 4.6.0
1762 * @return boolean
1763 */
1764 public function is_featured_service( $service ) {
1765 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1766 return ! empty( $service['featured'] );
1767 }
1768
1769 /**
1770 * Is this a non featured service?
1771 *
1772 * @param array $service Service info array.
1773 *
1774 * @deprecated 4.6.0
1775 * @return boolean
1776 */
1777 public function is_not_featured_service( $service ) {
1778 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1779 return ! $this->is_featured_service( $service );
1780 }
1781
1782 /**
1783 * Payment Step.
1784 *
1785 * @deprecated 4.6.0
1786 * @return void
1787 */
1788 public function wc_setup_payment() {
1789 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1790 $featured_gateways = array_filter( $this->get_wizard_in_cart_payment_gateways(), array( $this, 'is_featured_service' ) );
1791 $in_cart_gateways = array_filter( $this->get_wizard_in_cart_payment_gateways(), array( $this, 'is_not_featured_service' ) );
1792 $manual_gateways = $this->get_wizard_manual_payment_gateways();
1793 ?>
1794 <h1><?php esc_html_e( 'Payment', 'woocommerce' ); ?></h1>
1795 <form method="post" class="wc-wizard-payment-gateway-form">
1796 <p>
1797 <?php
1798 printf(
1799 wp_kses(
1800 /* translators: %s: Link */
1801 __( 'WooCommerce can accept both online and offline payments. <a href="%s" target="_blank">Additional payment methods</a> can be installed later.', 'woocommerce' ),
1802 array(
1803 'a' => array(
1804 'href' => array(),
1805 'target' => array(),
1806 ),
1807 )
1808 ),
1809 esc_url( admin_url( 'admin.php?page=wc-addons&section=payment-gateways' ) )
1810 );
1811 ?>
1812 </p>
1813 <?php if ( $featured_gateways ) : ?>
1814 <ul class="wc-wizard-services featured">
1815 <?php
1816 foreach ( $featured_gateways as $gateway_id => $gateway ) {
1817 $this->display_service_item( $gateway_id, $gateway );
1818 }
1819 ?>
1820 </ul>
1821 <?php endif; ?>
1822 <?php if ( $in_cart_gateways ) : ?>
1823 <ul class="wc-wizard-services in-cart">
1824 <?php
1825 foreach ( $in_cart_gateways as $gateway_id => $gateway ) {
1826 $this->display_service_item( $gateway_id, $gateway );
1827 }
1828 ?>
1829 </ul>
1830 <?php endif; ?>
1831 <ul class="wc-wizard-services manual">
1832 <li class="wc-wizard-services-list-toggle closed">
1833 <div class="wc-wizard-service-name">
1834 <?php esc_html_e( 'Offline Payments', 'woocommerce' ); ?>
1835 </div>
1836 <div class="wc-wizard-service-description">
1837 <?php esc_html_e( 'Collect payments from customers offline.', 'woocommerce' ); ?>
1838 </div>
1839 <div class="wc-wizard-service-enable" tabindex="0">
1840 <input class="wc-wizard-service-list-toggle" id="wc-wizard-service-list-toggle" type="checkbox">
1841 <label for="wc-wizard-service-list-toggle"></label>
1842 </div>
1843 </li>
1844 <?php
1845 foreach ( $manual_gateways as $gateway_id => $gateway ) {
1846 $this->display_service_item( $gateway_id, $gateway );
1847 }
1848 ?>
1849 </ul>
1850 <p class="wc-setup-actions step">
1851 <?php $this->plugin_install_info(); ?>
1852 <button type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Continue', 'woocommerce' ); ?></button>
1853 <?php wp_nonce_field( 'wc-setup' ); ?>
1854 </p>
1855 </form>
1856 <?php
1857 }
1858
1859 /**
1860 * Payment Step save.
1861 *
1862 * @deprecated 4.6.0
1863 * @return void
1864 */
1865 public function wc_setup_payment_save() {
1866 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1867 }
1868
1869 /**
1870 * Display recommended item.
1871 *
1872 * @param array $item_info Item info array.
1873 *
1874 * @deprecated 4.6.0
1875 * @return void
1876 */
1877 protected function display_recommended_item( $item_info ) {
1878 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1879 $type = $item_info['type'];
1880 $title = $item_info['title'];
1881 $description = $item_info['description'];
1882 $img_url = $item_info['img_url'];
1883 $img_alt = $item_info['img_alt'];
1884 ?>
1885 <li class="recommended-item checkbox">
1886 <input
1887 id="<?php echo esc_attr( 'wc_recommended_' . $type ); ?>"
1888 type="checkbox"
1889 name="<?php echo esc_attr( 'setup_' . $type ); ?>"
1890 value="yes"
1891 checked
1892 data-plugins="<?php echo wc_esc_json( wp_json_encode( isset( $item_info['plugins'] ) ? $item_info['plugins'] : null ) ); ?>"
1893 />
1894 <label for="<?php echo esc_attr( 'wc_recommended_' . $type ); ?>">
1895 <img
1896 src="<?php echo esc_url( $img_url ); ?>"
1897 class="<?php echo esc_attr( 'recommended-item-icon-' . $type ); ?> recommended-item-icon"
1898 alt="<?php echo esc_attr( $img_alt ); ?>" />
1899 <div class="recommended-item-description-container">
1900 <h3><?php echo esc_html( $title ); ?></h3>
1901 <p><?php echo wp_kses( $description, array(
1902 'a' => array(
1903 'href' => array(),
1904 'target' => array(),
1905 'rel' => array(),
1906 ),
1907 'em' => array(),
1908 ) ); ?></p>
1909 </div>
1910 </label>
1911 </li>
1912 <?php
1913 }
1914
1915 /**
1916 * Recommended step
1917 *
1918 * @deprecated 4.6.0
1919 * @return void
1920 */
1921 public function wc_setup_recommended() {
1922 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
1923 ?>
1924 <h1><?php esc_html_e( 'Recommended for All WooCommerce Stores', 'woocommerce' ); ?></h1>
1925 <p>
1926 <?php esc_html_e( 'Enhance your store with these recommended free features.', 'woocommerce' ); ?>
1927 </p>
1928 <form method="post">
1929 <ul class="recommended-step">
1930 <?php
1931 if ( $this->should_show_theme() ) :
1932 $theme = wp_get_theme();
1933 $theme_name = $theme['Name'];
1934 $this->display_recommended_item( array(
1935 'type' => 'storefront_theme',
1936 'title' => __( 'Storefront Theme', 'woocommerce' ),
1937 'description' => sprintf(
1938 /* translators: %s: theme name. */
1939 __(
1940 'Design your store with deep WooCommerce integration. If toggled on, we’ll install <a href="https://woocommerce.com/storefront/" target="_blank" rel="noopener noreferrer">Storefront</a>, and your current theme <em>%s</em> will be deactivated.',
1941 'woocommerce'
1942 ),
1943 $theme_name
1944 ),
1945 'img_url' => WC()->plugin_url() . '/assets/images/obw-storefront-icon.svg',
1946 'img_alt' => __( 'Storefront icon', 'woocommerce' ),
1947 ) );
1948 endif;
1949
1950 if ( $this->should_show_automated_tax() ) :
1951 $this->display_recommended_item( array(
1952 'type' => 'automated_taxes',
1953 'title' => __( 'Automated Taxes', 'woocommerce' ),
1954 'description' => __( 'Save time and errors with automated tax calculation and collection at checkout. Powered by WooCommerce Services and Jetpack.', 'woocommerce' ),
1955 'img_url' => WC()->plugin_url() . '/assets/images/obw-taxes-icon.svg',
1956 'img_alt' => __( 'automated taxes icon', 'woocommerce' ),
1957 'plugins' => $this->get_wcs_requisite_plugins(),
1958 ) );
1959 endif;
1960
1961 if ( $this->should_show_wc_admin() ) :
1962 $this->display_recommended_item( array(
1963 'type' => 'wc_admin',
1964 'title' => __( 'WooCommerce Admin', 'woocommerce' ),
1965 'description' => __( 'Manage your store\'s reports and monitor key metrics with a new and improved interface and dashboard.', 'woocommerce' ),
1966 'img_url' => WC()->plugin_url() . '/assets/images/obw-woocommerce-admin-icon.svg',
1967 'img_alt' => __( 'WooCommerce Admin icon', 'woocommerce' ),
1968 'plugins' => array( array( 'name' => __( 'WooCommerce Admin', 'woocommerce' ), 'slug' => 'woocommerce-admin' ) ),
1969 ) );
1970 endif;
1971
1972 if ( $this->should_show_mailchimp() ) :
1973 $this->display_recommended_item( array(
1974 'type' => 'mailchimp',
1975 'title' => __( 'Mailchimp', 'woocommerce' ),
1976 'description' => __( 'Join the 16 million customers who use Mailchimp. Sync list and store data to send automated emails, and targeted campaigns.', 'woocommerce' ),
1977 'img_url' => WC()->plugin_url() . '/assets/images/obw-mailchimp-icon.svg',
1978 'img_alt' => __( 'Mailchimp icon', 'woocommerce' ),
1979 'plugins' => array( array( 'name' => __( 'Mailchimp for WooCommerce', 'woocommerce' ), 'slug' => 'mailchimp-for-woocommerce' ) ),
1980 ) );
1981 endif;
1982
1983 if ( $this->should_show_facebook() ) :
1984 $this->display_recommended_item( array(
1985 'type' => 'facebook',
1986 'title' => __( 'Facebook', 'woocommerce' ),
1987 'description' => __( 'Enjoy all Facebook products combined in one extension: pixel tracking, catalog sync, messenger chat, shop functionality and Instagram shopping (coming soon)!', 'woocommerce' ),
1988 'img_url' => WC()->plugin_url() . '/assets/images/obw-facebook-icon.svg',
1989 'img_alt' => __( 'Facebook icon', 'woocommerce' ),
1990 'plugins' => array( array( 'name' => __( 'Facebook for WooCommerce', 'woocommerce' ), 'slug' => 'facebook-for-woocommerce' ) ),
1991 ) );
1992 endif;
1993 ?>
1994 </ul>
1995 <p class="wc-setup-actions step">
1996 <?php $this->plugin_install_info(); ?>
1997 <button type="submit" class="button-primary button button-large button-next" value="<?php esc_attr_e( 'Continue', 'woocommerce' ); ?>" name="save_step"><?php esc_html_e( 'Continue', 'woocommerce' ); ?></button>
1998 <?php wp_nonce_field( 'wc-setup' ); ?>
1999 </p>
2000 </form>
2001 <?php
2002 }
2003
2004 /**
2005 * Recommended step save.
2006 *
2007 * @deprecated 4.6.0
2008 * @return void
2009 */
2010 public function wc_setup_recommended_save() {
2011 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
2012 }
2013
2014 /**
2015 * Go to the next step if Jetpack was connected.
2016 *
2017 * @return void
2018 */
2019 protected function wc_setup_activate_actions() {
2020 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
2021 if (
2022 isset( $_GET['from'] ) &&
2023 'wpcom' === $_GET['from'] &&
2024 class_exists( 'Jetpack' ) &&
2025 Jetpack::is_active()
2026 ) {
2027 wp_redirect( esc_url_raw( remove_query_arg( 'from', $this->get_next_step_link() ) ) );
2028 exit;
2029 }
2030 }
2031
2032 /**
2033 * Get feature list for activation.
2034 *
2035 * @deprecated 4.6.0
2036 * @return array
2037 */
2038 protected function wc_setup_activate_get_feature_list() {
2039 $features = array();
2040
2041 $stripe_settings = get_option( 'woocommerce_stripe_settings', false );
2042 $stripe_enabled = is_array( $stripe_settings )
2043 && isset( $stripe_settings['create_account'] ) && 'yes' === $stripe_settings['create_account']
2044 && isset( $stripe_settings['enabled'] ) && 'yes' === $stripe_settings['enabled'];
2045 $ppec_settings = get_option( 'woocommerce_ppec_paypal_settings', false );
2046 $ppec_enabled = is_array( $ppec_settings )
2047 && isset( $ppec_settings['reroute_requests'] ) && 'yes' === $ppec_settings['reroute_requests']
2048 && isset( $ppec_settings['enabled'] ) && 'yes' === $ppec_settings['enabled'];
2049
2050 $features['payment'] = $stripe_enabled || $ppec_enabled;
2051 $features['taxes'] = (bool) get_option( 'woocommerce_setup_automated_taxes', false );
2052 $features['labels'] = (bool) get_option( 'woocommerce_setup_shipping_labels', false );
2053
2054 return $features;
2055 }
2056
2057 /**
2058 * Get feature list string for activation.
2059 *
2060 * @deprecated 4.6.0
2061 * @return string|false
2062 */
2063 protected function wc_setup_activate_get_feature_list_str() {
2064 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
2065 $features = $this->wc_setup_activate_get_feature_list();
2066 if ( $features['payment'] && $features['taxes'] && $features['labels'] ) {
2067 return __( 'payment setup, automated taxes and discounted shipping labels', 'woocommerce' );
2068 } else if ( $features['payment'] && $features['taxes'] ) {
2069 return __( 'payment setup and automated taxes', 'woocommerce' );
2070 } else if ( $features['payment'] && $features['labels'] ) {
2071 return __( 'payment setup and discounted shipping labels', 'woocommerce' );
2072 } else if ( $features['payment'] ) {
2073 return __( 'payment setup', 'woocommerce' );
2074 } else if ( $features['taxes'] && $features['labels'] ) {
2075 return __( 'automated taxes and discounted shipping labels', 'woocommerce' );
2076 } else if ( $features['taxes'] ) {
2077 return __( 'automated taxes', 'woocommerce' );
2078 } else if ( $features['labels'] ) {
2079 return __( 'discounted shipping labels', 'woocommerce' );
2080 }
2081 return false;
2082 }
2083
2084 /**
2085 * Activate step.
2086 *
2087 * @deprecated 4.6.0
2088 * @return void
2089 */
2090 public function wc_setup_activate() {
2091 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
2092 $this->wc_setup_activate_actions();
2093
2094 $jetpack_connected = class_exists( 'Jetpack' ) && Jetpack::is_active();
2095
2096 $has_jetpack_error = false;
2097 if ( isset( $_GET['activate_error'] ) ) {
2098 $has_jetpack_error = true;
2099
2100 $title = __( "Sorry, we couldn't connect your store to Jetpack", 'woocommerce' );
2101
2102 $error_message = $this->get_activate_error_message( sanitize_text_field( wp_unslash( $_GET['activate_error'] ) ) );
2103 $description = $error_message;
2104 } else {
2105 $feature_list = $this->wc_setup_activate_get_feature_list_str();
2106
2107 $description = false;
2108
2109 if ( $feature_list ) {
2110 if ( ! $jetpack_connected ) {
2111 /* translators: %s: list of features, potentially comma separated */
2112 $description_base = __( 'Your store is almost ready! To activate services like %s, just connect with Jetpack.', 'woocommerce' );
2113 } else {
2114 $description_base = __( 'Thanks for using Jetpack! Your store is almost ready: to activate services like %s, just connect your store.', 'woocommerce' );
2115 }
2116 $description = sprintf( $description_base, $feature_list );
2117 }
2118
2119 if ( ! $jetpack_connected ) {
2120 $title = $feature_list ?
2121 __( 'Connect your store to Jetpack', 'woocommerce' ) :
2122 __( 'Connect your store to Jetpack to enable extra features', 'woocommerce' );
2123 $button_text = __( 'Continue with Jetpack', 'woocommerce' );
2124 } elseif ( $feature_list ) {
2125 $title = __( 'Connect your store to activate WooCommerce Services', 'woocommerce' );
2126 $button_text = __( 'Continue with WooCommerce Services', 'woocommerce' );
2127 } else {
2128 wp_redirect( esc_url_raw( $this->get_next_step_link() ) );
2129 exit;
2130 }
2131 }
2132 ?>
2133 <h1><?php echo esc_html( $title ); ?></h1>
2134 <p><?php echo esc_html( (string) $description ); ?></p>
2135
2136 <?php if ( $jetpack_connected ) : ?>
2137 <div class="activate-splash">
2138 <img
2139 class="jetpack-logo"
2140 src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/jetpack_horizontal_logo.png' ); ?>"
2141 alt="<?php esc_attr_e( 'Jetpack logo', 'woocommerce' ); ?>"
2142 />
2143 <img
2144 class="wcs-notice"
2145 src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/wcs-notice.png' ); ?>"
2146 />
2147 </div>
2148 <?php else : ?>
2149 <img
2150 class="jetpack-logo"
2151 src="<?php echo esc_url( WC()->plugin_url() . '/assets/images/jetpack_vertical_logo.png' ); ?>"
2152 alt="<?php esc_attr_e( 'Jetpack logo', 'woocommerce' ); ?>"
2153 />
2154 <?php endif; ?>
2155
2156 <?php if ( $has_jetpack_error ) : ?>
2157 <p class="wc-setup-actions step">
2158 <a
2159 href="<?php echo esc_url( $this->get_next_step_link() ); ?>"
2160 class="button-primary button button-large"
2161 >
2162 <?php esc_html_e( 'Finish setting up your store', 'woocommerce' ); ?>
2163 </a>
2164 </p>
2165 <?php else : ?>
2166 <p class="jetpack-terms">
2167 <?php
2168 printf(
2169 wp_kses_post( __( 'By connecting your site you agree to our fascinating <a href="%1$s" target="_blank">Terms of Service</a> and to <a href="%2$s" target="_blank">share details</a> with WordPress.com', 'woocommerce' ) ),
2170 'https://wordpress.com/tos',
2171 'https://jetpack.com/support/what-data-does-jetpack-sync'
2172 );
2173 ?>
2174 </p>
2175 <form method="post" class="activate-jetpack">
2176 <p class="wc-setup-actions step">
2177 <button type="submit" class="button-primary button button-large" value="<?php echo esc_attr( $button_text ); ?>"><?php echo esc_html( $button_text ); ?></button>
2178 </p>
2179 <input type="hidden" name="save_step" value="activate" />
2180 <?php wp_nonce_field( 'wc-setup' ); ?>
2181 </form>
2182 <?php if ( ! $jetpack_connected ) : ?>
2183 <h3 class="jetpack-reasons">
2184 <?php
2185 echo esc_html( $description ?
2186 __( "Bonus reasons you'll love Jetpack", 'woocommerce' ) :
2187 __( "Reasons you'll love Jetpack", 'woocommerce' )
2188 );
2189 ?>
2190 </h3>
2191 <ul class="wc-wizard-features">
2192 <li class="wc-wizard-feature-item">
2193 <p class="wc-wizard-feature-name">
2194 <strong><?php esc_html_e( 'Better security', 'woocommerce' ); ?></strong>
2195 </p>
2196 <p class="wc-wizard-feature-description">
2197 <?php esc_html_e( 'Protect your store from unauthorized access.', 'woocommerce' ); ?>
2198 </p>
2199 </li>
2200 <li class="wc-wizard-feature-item">
2201 <p class="wc-wizard-feature-name">
2202 <strong><?php esc_html_e( 'Store stats', 'woocommerce' ); ?></strong>
2203 </p>
2204 <p class="wc-wizard-feature-description">
2205 <?php esc_html_e( 'Get insights on how your store is doing, including total sales, top products, and more.', 'woocommerce' ); ?>
2206 </p>
2207 </li>
2208 <li class="wc-wizard-feature-item">
2209 <p class="wc-wizard-feature-name">
2210 <strong><?php esc_html_e( 'Store monitoring', 'woocommerce' ); ?></strong>
2211 </p>
2212 <p class="wc-wizard-feature-description">
2213 <?php esc_html_e( 'Get an alert if your store is down for even a few minutes.', 'woocommerce' ); ?>
2214 </p>
2215 </li>
2216 <li class="wc-wizard-feature-item">
2217 <p class="wc-wizard-feature-name">
2218 <strong><?php esc_html_e( 'Product promotion', 'woocommerce' ); ?></strong>
2219 </p>
2220 <p class="wc-wizard-feature-description">
2221 <?php esc_html_e( "Share new items on social media the moment they're live in your store.", 'woocommerce' ); ?>
2222 </p>
2223 </li>
2224 </ul>
2225 <?php endif; ?>
2226 <?php endif; ?>
2227 <?php
2228 }
2229
2230 /**
2231 * Get all activate errors.
2232 *
2233 * @deprecated 4.6.0
2234 * @return array
2235 */
2236 protected function get_all_activate_errors() {
2237 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
2238 return array(
2239 'default' => __( "Sorry! We tried, but we couldn't connect Jetpack just now 😭. Please go to the Plugins tab to connect Jetpack, so that you can finish setting up your store.", 'woocommerce' ),
2240 'jetpack_cant_be_installed' => __( "Sorry! We tried, but we couldn't install Jetpack for you 😭. Please go to the Plugins tab to install it, and finish setting up your store.", 'woocommerce' ),
2241 'register_http_request_failed' => __( "Sorry! We couldn't contact Jetpack just now 😭. Please make sure that your site is visible over the internet, and that it accepts incoming and outgoing requests via curl. You can also try to connect to Jetpack again, and if you run into any more issues, please contact support.", 'woocommerce' ),
2242 'siteurl_private_ip_dev' => __( "Your site might be on a private network. Jetpack can only connect to public sites. Please make sure your site is visible over the internet, and then try connecting again 🙏." , 'woocommerce' ),
2243 );
2244 }
2245
2246 /**
2247 * Get activate error message.
2248 *
2249 * @param string $code Error code.
2250 *
2251 * @deprecated 4.6.0
2252 * @return string
2253 */
2254 protected function get_activate_error_message( $code = '' ) {
2255 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
2256 $errors = $this->get_all_activate_errors();
2257 return array_key_exists( $code, $errors ) ? $errors[ $code ] : $errors['default'];
2258 }
2259
2260 /**
2261 * Activate step save.
2262 *
2263 * Install, activate, and launch connection flow for Jetpack.
2264 *
2265 * @deprecated 4.6.0
2266 * @return void
2267 */
2268 public function wc_setup_activate_save() {
2269 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
2270 }
2271
2272 /**
2273 * Final step.
2274 *
2275 * @deprecated 4.6.0
2276 * @return void
2277 */
2278 public function wc_setup_ready() {
2279 _deprecated_function( __CLASS__ . '::' . __FUNCTION__, '4.6.0', 'Onboarding is maintained in WooCommerce Admin.' );
2280 // We've made it! Don't prompt the user to run the wizard again.
2281 WC_Admin_Notices::remove_notice( 'install', true );
2282
2283 $user_email = $this->get_current_user_email();
2284 $docs_url = 'https://woocommerce.com/documentation/plugins/woocommerce/getting-started/?utm_source=setupwizard&utm_medium=product&utm_content=docs&utm_campaign=woocommerceplugin';
2285 $help_text = sprintf(
2286 /* translators: %1$s: link to docs */
2287 __( 'Visit WooCommerce.com to learn more about <a href="%1$s" target="_blank">getting started</a>.', 'woocommerce' ),
2288 $docs_url
2289 );
2290 ?>
2291 <h1><?php esc_html_e( "You're ready to start selling!", 'woocommerce' ); ?></h1>
2292
2293 <div class="woocommerce-message woocommerce-newsletter">
2294 <p><?php esc_html_e( "We're here for you — get tips, product updates, and inspiration straight to your mailbox.", 'woocommerce' ); ?></p>
2295 <form action="//woocommerce.us8.list-manage.com/subscribe/post?u=2c1434dc56f9506bf3c3ecd21&amp;id=13860df971&amp;SIGNUPPAGE=plugin" method="post" target="_blank" novalidate>
2296 <div class="newsletter-form-container">
2297 <input
2298 class="newsletter-form-email"
2299 type="email"
2300 value="<?php echo esc_attr( $user_email ); ?>"
2301 name="EMAIL"
2302 placeholder="<?php esc_attr_e( 'Email address', 'woocommerce' ); ?>"
2303 required
2304 >
2305 <p class="wc-setup-actions step newsletter-form-button-container">
2306 <button
2307 type="submit"
2308 value="<?php esc_attr_e( 'Yes please!', 'woocommerce' ); ?>"
2309 name="subscribe"
2310 id="mc-embedded-subscribe"
2311 class="button-primary button newsletter-form-button"
2312 ><?php esc_html_e( 'Yes please!', 'woocommerce' ); ?></button>
2313 </p>
2314 </div>
2315 </form>
2316 </div>
2317
2318 <ul class="wc-wizard-next-steps">
2319 <li class="wc-wizard-next-step-item">
2320 <div class="wc-wizard-next-step-description">
2321 <p class="next-step-heading"><?php esc_html_e( 'Next step', 'woocommerce' ); ?></p>
2322 <h3 class="next-step-description"><?php esc_html_e( 'Create some products', 'woocommerce' ); ?></h3>
2323 <p class="next-step-extra-info"><?php esc_html_e( "You're ready to add products to your store.", 'woocommerce' ); ?></p>
2324 </div>
2325 <div class="wc-wizard-next-step-action">
2326 <p class="wc-setup-actions step">
2327 <a class="button button-primary button-large" href="<?php echo esc_url( admin_url( 'post-new.php?post_type=product&tutorial=true' ) ); ?>">
2328 <?php esc_html_e( 'Create a product', 'woocommerce' ); ?>
2329 </a>
2330 </p>
2331 </div>
2332 </li>
2333 <li class="wc-wizard-next-step-item">
2334 <div class="wc-wizard-next-step-description">
2335 <p class="next-step-heading"><?php esc_html_e( 'Have an existing store?', 'woocommerce' ); ?></p>
2336 <h3 class="next-step-description"><?php esc_html_e( 'Import products', 'woocommerce' ); ?></h3>
2337 <p class="next-step-extra-info"><?php esc_html_e( 'Transfer existing products to your new store — just import a CSV file.', 'woocommerce' ); ?></p>
2338 </div>
2339 <div class="wc-wizard-next-step-action">
2340 <p class="wc-setup-actions step">
2341 <a class="button button-large" href="<?php echo esc_url( admin_url( 'edit.php?post_type=product&page=product_importer' ) ); ?>">
2342 <?php esc_html_e( 'Import products', 'woocommerce' ); ?>
2343 </a>
2344 </p>
2345 </div>
2346 </li>
2347 <li class="wc-wizard-additional-steps">
2348 <div class="wc-wizard-next-step-description">
2349 <p class="next-step-heading"><?php esc_html_e( 'You can also:', 'woocommerce' ); ?></p>
2350 </div>
2351 <div class="wc-wizard-next-step-action">
2352 <p class="wc-setup-actions step">
2353 <a class="button button-large" href="<?php echo esc_url( admin_url() ); ?>">
2354 <?php esc_html_e( 'Visit Dashboard', 'woocommerce' ); ?>
2355 </a>
2356 <a class="button button-large" href="<?php echo esc_url( admin_url( 'admin.php?page=wc-settings' ) ); ?>">
2357 <?php esc_html_e( 'Review Settings', 'woocommerce' ); ?>
2358 </a>
2359 <a class="button button-large" href="<?php echo esc_url( add_query_arg( array( 'autofocus' => array( 'panel' => 'woocommerce' ), 'url' => wc_get_page_permalink( 'shop' ) ), admin_url( 'customize.php' ) ) ); ?>">
2360 <?php esc_html_e( 'View &amp; Customize', 'woocommerce' ); ?>
2361 </a>
2362 </p>
2363 </div>
2364 </li>
2365 </ul>
2366 <p class="next-steps-help-text"><?php echo wp_kses_post( $help_text ); ?></p>
2367 <?php
2368 }
2369 }
2370
2371