PluginProbe
Subscriptions for WooCommerce with Stripe Recurring Payments / 2.1.0
Subscriptions for WooCommerce with Stripe Recurring Payments v2.1.0
2.4.0 2.3.0 2.2.0 2.1.0 2.0.0 1.11.2 1.11.1 1.11.0 1.10.9 1.10.8 1.10.7 1.10.6 1.10.5 1.10.4 1.10.3 1.10.2 1.10.1 1.10.0 1.9.6 1.9.5 trunk 1.3.0 1.3.1 1.3.2 1.4.0 All 65 releases
← All changes | includes/Api/PlanController.php +0 -86 2.4.0 → 2.1.0 View file →
@@ -84,20 +84,8 @@
84 84 );
85 85
86 86 register_rest_route(
87 87 self::NS,
88 - '/plans/groups/(?P<id>\d+)/order',
89 - array(
90 - array(
91 - 'methods' => WP_REST_Server::EDITABLE,
92 - 'callback' => array( $this, 'update_group_order' ),
93 - 'permission_callback' => $perm,
94 - ),
95 - )
96 - );
97 -
98 - register_rest_route(
99 - self::NS,
100 88 '/plans/terms',
101 89 array(
102 90 array(
103 91 'methods' => WP_REST_Server::CREATABLE,
@@ -195,20 +183,8 @@
195 183 );
196 184
197 185 register_rest_route(
198 186 self::NS,
199 - '/plans/product-user-cancel/(?P<id>\d+)',
200 - array(
201 - array(
202 - 'methods' => WP_REST_Server::EDITABLE,
203 - 'callback' => array( $this, 'save_product_user_cancel' ),
204 - 'permission_callback' => $perm,
205 - ),
206 - )
207 - );
208 -
209 - register_rest_route(
210 - self::NS,
211 187 '/plans/group-products/(?P<id>\d+)',
212 188 array(
213 189 array(
214 190 'methods' => WP_REST_Server::READABLE,
@@ -400,44 +376,8 @@
400 376 return rest_ensure_response( PlanRepository::get_group_tree( $id ) );
401 377 }
402 378
403 379 /**
404 - * PUT /plans/groups/{id}/order - save the admin display order of the
405 - * group's durations and/or products (drag-and-drop on the detail page).
406 - *
407 - * Stored in the group's `data` JSON as `term_order` / `product_order`
408 - * (lists of ids), merged so the rest of `data` is left as it was.
409 - *
410 - * @param WP_REST_Request $request Request.
411 - *
412 - * @return \WP_REST_Response|WP_Error
413 - */
414 - public function update_group_order( WP_REST_Request $request ) {
415 - $id = (int) $request['id'];
416 - $group = PlanRepository::get_group( $id );
417 -
418 - if ( ! $group ) {
419 - return $this->not_found();
420 - }
421 -
422 - $params = $this->read_params( $request );
423 - $data = is_array( $group['data'] ) ? $group['data'] : array();
424 -
425 - foreach ( array(
426 - 'terms' => 'term_order',
427 - 'products' => 'product_order',
428 - ) as $param => $key ) {
429 - if ( isset( $params[ $param ] ) && is_array( $params[ $param ] ) ) {
430 - $data[ $key ] = array_values( array_unique( array_filter( array_map( 'absint', $params[ $param ] ) ) ) );
431 - }
432 - }
433 -
434 - PlanRepository::update_group( $id, array( 'data' => $data ) );
435 -
436 - return rest_ensure_response( array( 'success' => true ) );
437 - }
438 -
439 - /**
440 380 * DELETE /plans/groups/{id} - delete group + cascade.
441 381 *
442 382 * @param WP_REST_Request $request Request.
443 383 *
@@ -655,34 +595,8 @@
655 595 'deleted' => true,
656 596 'id' => $id,
657 597 )
658 598 );
659 - }
660 -
661 - /**
662 - * PUT /plans/product-user-cancel/{id} - save whether customers may cancel.
663 - *
664 - * Writes the same `_subscrpt_user_cancel` meta the product editor saves, as
665 - * an explicit "yes" / "no", which checkout copies onto each new subscription.
666 - *
667 - * Body: { enabled: bool }.
668 - *
669 - * @param WP_REST_Request $request Request.
670 - *
671 - * @return \WP_REST_Response|WP_Error
672 - */
673 - public function save_product_user_cancel( WP_REST_Request $request ) {
674 - $product = function_exists( 'wc_get_product' ) ? wc_get_product( (int) $request['id'] ) : null;
675 -
676 - if ( ! $product ) {
677 - return $this->not_found();
678 - }
679 -
680 - $params = $this->read_params( $request );
681 - $product->update_meta_data( '_subscrpt_user_cancel', empty( $params['enabled'] ) ? 'no' : 'yes' );
682 - $product->save();
683 -
684 - return rest_ensure_response( array( 'saved' => true ) );
685 599 }
686 600
687 601 /**
688 602 * POST /plans/bulk-price - set one price on many product/duration relations.