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.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 / src / Admin / API / LaunchYourStore.php
woocommerce / src / Admin / API Last commit date
AI 1 year ago RateLimits 4 weeks ago Reports 4 weeks ago Templates 3 years ago views 4 weeks ago AnalyticsImports.php 5 months ago Coupons.php 4 years ago CustomAttributeTraits.php 4 years ago Customers.php 4 years ago Data.php 4 years ago DataCountries.php 4 years ago DataDownloadIPs.php 4 years ago Experiments.php 4 years ago Features.php 4 years ago Init.php 4 weeks ago LaunchYourStore.php 1 year ago Leaderboards.php 1 year ago Marketing.php 2 months ago MarketingCampaignTypes.php 3 years ago MarketingCampaigns.php 2 years ago MarketingChannels.php 3 years ago MarketingOverview.php 2 months ago MarketingRecommendations.php 2 years ago MobileAppMagicLink.php 3 years ago MobileAppQRLogin.php 4 weeks ago NoteActions.php 4 weeks ago Notes.php 4 weeks ago Notice.php 1 year ago OnboardingFreeExtensions.php 1 year ago OnboardingPlugins.php 4 weeks ago OnboardingProductTypes.php 4 years ago OnboardingProducts.php 2 years ago OnboardingProfile.php 1 year ago OnboardingTasks.php 9 months ago OnboardingThemes.php 9 months ago Options.php 4 weeks ago Orders.php 1 year ago PaymentGatewaySuggestions.php 2 months ago Plugins.php 2 months ago ProductAttributeTerms.php 4 years ago ProductAttributes.php 4 years ago ProductCategories.php 4 years ago ProductForm.php 3 years ago ProductReviews.php 4 years ago ProductVariations.php 1 year ago Products.php 1 year ago ProductsLowInStock.php 4 months ago SettingOptions.php 3 years ago ShippingPartnerSuggestions.php 1 month ago Taxes.php 4 years ago Themes.php 2 years ago
LaunchYourStore.php
223 lines
1 <?php
2 /**
3 * REST API Launch Your Store Controller
4 *
5 * Handles requests to /launch-your-store/*
6 */
7
8 namespace Automattic\WooCommerce\Admin\API;
9
10 use Automattic\WooCommerce\Admin\WCAdminHelper;
11
12 defined( 'ABSPATH' ) || exit;
13
14 /**
15 * Launch Your Store controller.
16 *
17 * @internal
18 */
19 class LaunchYourStore {
20
21 /**
22 * Endpoint namespace.
23 *
24 * @var string
25 */
26 protected $namespace = 'wc-admin';
27
28 /**
29 * Route base.
30 *
31 * @var string
32 */
33 protected $rest_base = 'launch-your-store';
34
35 /**
36 * Register routes.
37 */
38 public function register_routes() {
39 register_rest_route(
40 $this->namespace,
41 '/' . $this->rest_base . '/initialize-coming-soon',
42 array(
43 array(
44 'methods' => 'POST',
45 'callback' => array( $this, 'initialize_coming_soon' ),
46 'permission_callback' => array( $this, 'must_be_shop_manager_or_admin' ),
47 ),
48 )
49 );
50
51 register_rest_route(
52 $this->namespace,
53 '/' . $this->rest_base . '/update-survey-status',
54 array(
55 array(
56 'methods' => 'POST',
57 'callback' => array( $this, 'update_survey_status' ),
58 'permission_callback' => array( $this, 'must_be_shop_manager_or_admin' ),
59 'args' => array(
60 'status' => array(
61 'type' => 'string',
62 'enum' => array( 'yes', 'no' ),
63 ),
64 ),
65 ),
66 )
67 );
68
69 register_rest_route(
70 $this->namespace,
71 '/' . $this->rest_base . '/survey-completed',
72 array(
73 array(
74 'methods' => 'GET',
75 'callback' => array( $this, 'has_survey_completed' ),
76 'permission_callback' => array( $this, 'must_be_shop_manager_or_admin' ),
77 ),
78 )
79 );
80
81 register_rest_route(
82 $this->namespace,
83 '/' . $this->rest_base . '/woopayments/test-orders/count',
84 array(
85 array(
86 'methods' => 'GET',
87 'callback' => array( $this, 'get_woopay_test_orders_count' ),
88 'permission_callback' => array( $this, 'must_be_shop_manager_or_admin' ),
89 ),
90 )
91 );
92
93 register_rest_route(
94 $this->namespace,
95 '/' . $this->rest_base . '/woopayments/test-orders',
96 array(
97 array(
98 'methods' => 'DELETE',
99 'callback' => array( $this, 'delete_woopay_test_orders' ),
100 'permission_callback' => array( $this, 'must_be_shop_manager_or_admin' ),
101 ),
102 )
103 );
104 }
105
106 /**
107 * User must be either shop_manager or administrator.
108 *
109 * @return bool
110 */
111 public function must_be_shop_manager_or_admin() {
112 // phpcs:ignore
113 if ( ! current_user_can( 'manage_woocommerce' ) && ! current_user_can( 'administrator' ) ) {
114 return false;
115 }
116 return true;
117 }
118
119 /**
120 * Initializes options for coming soon. Overwrites existing coming soon status but keeps the private link and share key.
121 *
122 * @return bool|void
123 */
124 public function initialize_coming_soon() {
125 $current_user_id = get_current_user_id();
126 // Abort if we don't have a user id for some reason.
127 if ( ! $current_user_id ) {
128 return;
129 }
130
131 $coming_soon = 'yes';
132 $store_pages_only = WCAdminHelper::is_site_fresh() ? 'no' : 'yes';
133 $private_link = 'no';
134 $share_key = wp_generate_password( 32, false );
135
136 update_option( 'woocommerce_coming_soon', $coming_soon );
137 update_option( 'woocommerce_store_pages_only', $store_pages_only );
138 add_option( 'woocommerce_private_link', $private_link );
139 add_option( 'woocommerce_share_key', $share_key );
140
141 wc_admin_record_tracks_event(
142 'launch_your_store_initialize_coming_soon',
143 array(
144 'coming_soon' => $coming_soon,
145 'store_pages_only' => $store_pages_only,
146 'private_link' => $private_link,
147 )
148 );
149
150 return true;
151 }
152
153 /**
154 * Count the test orders created during Woo Payments test mode.
155 *
156 * @return \WP_REST_Response
157 */
158 public function get_woopay_test_orders_count() {
159 $return = function ( $count ) {
160 return new \WP_REST_Response( array( 'count' => $count ) );
161 };
162
163 $orders = wc_get_orders(
164 array(
165 // phpcs:ignore
166 'meta_key' => '_wcpay_mode',
167 // phpcs:ignore
168 'meta_value' => 'test',
169 'return' => 'ids',
170 )
171 );
172
173 return $return( count( $orders ) );
174 }
175
176 /**
177 * Delete WooPayments test orders.
178 *
179 * @return \WP_REST_Response
180 */
181 public function delete_woopay_test_orders() {
182 $return = function ( $status = 204 ) {
183 return new \WP_REST_Response( null, $status );
184 };
185
186 $orders = wc_get_orders(
187 array(
188 // phpcs:ignore
189 'meta_key' => '_wcpay_mode',
190 // phpcs:ignore
191 'meta_value' => 'test',
192 )
193 );
194
195 foreach ( $orders as $order ) {
196 $order->delete();
197 }
198
199 return $return();
200 }
201
202 /**
203 * Update woocommerce_admin_launch_your_store_survey_completed to yes or no
204 *
205 * @param \WP_REST_Request $request WP_REST_Request object.
206 *
207 * @return \WP_REST_Response
208 */
209 public function update_survey_status( \WP_REST_Request $request ) {
210 update_option( 'woocommerce_admin_launch_your_store_survey_completed', $request->get_param( 'status' ) );
211 return new \WP_REST_Response();
212 }
213
214 /**
215 * Return woocommerce_admin_launch_your_store_survey_completed option.
216 *
217 * @return \WP_REST_Response
218 */
219 public function has_survey_completed() {
220 return new \WP_REST_Response( get_option( 'woocommerce_admin_launch_your_store_survey_completed', 'no' ) );
221 }
222 }
223