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