Changeset 2821499
- Timestamp:
- 11/21/2022 12:06:07 PM (3 years ago)
- Location:
- shelfy-mobile-commerce-platform/trunk
- Files:
-
- 2 edited
-
includes/controllers/class-shelfy-cart-rest-api.php (modified) (2 diffs)
-
shelfy.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
shelfy-mobile-commerce-platform/trunk/includes/controllers/class-shelfy-cart-rest-api.php
r2786898 r2821499 109 109 'methods' => WP_REST_Server::EDITABLE, 110 110 'callback' => array( $this, 'batch_update_item_quantity' ), 111 'permission_callback' => '__return_true', 112 'args' => array( 113 'products' => array( 114 'type' => 'array', 115 'required' => true, 116 'items' => $this->get_update_item_quantity_schema(), 117 ), 118 ), 119 ) 120 ); 121 register_rest_route( 122 SHELFY_REST_API_NAMESPACE, 123 $this->api_base . '/items/batch/v2', 124 array( 125 'methods' => WP_REST_Server::EDITABLE, 126 'callback' => array( $this, 'batch_update_item_quantity_v2' ), 111 127 'permission_callback' => '__return_true', 112 128 'args' => array( … … 188 204 public function batch_update_item_quantity( $request ) { 189 205 wp_set_current_user(Shelfy_Cart_Rest_Api::$user_id); 206 $requests = $request['products']; 207 $batch_response = array(); 208 foreach ( $requests as $index => $request ) { 209 $response = $this->update_item_quantity( $request, true ); 210 if ( is_wp_error( $response ) ) { 211 $batch_response[] = array( 212 'requestIndex' => $index, 213 'message' => $response->get_error_message(), 214 'data' => $response->get_error_data(), 215 ); 216 } 217 } 218 $response = $this->get_cart_response(); 219 if ( ! empty( $batch_response ) ) { 220 $response['batch_errors'] = $batch_response; 221 } 222 return $response; 223 } 224 225 /** 226 * Empty the cart and than Updates cart items quantities in batches 227 * 228 * @param WP_REST_Request $request The REST request. 229 */ 230 public function batch_update_item_quantity_v2( $request ) { 231 wp_set_current_user(Shelfy_Cart_Rest_Api::$user_id); 232 WC()->cart->empty_cart(); 233 WC()->cart->calculate_totals(); 190 234 $requests = $request['products']; 191 235 $batch_response = array(); -
shelfy-mobile-commerce-platform/trunk/shelfy.php
r2786898 r2821499 5 5 * @package Shelfy plugin 6 6 * @wordpress-plugin 7 * Plugin Name: Shelfy - Mobile App Builder - Dev7 * Plugin Name: Shelfy - Mobile App Builder 8 8 * Description: Build fast mobile apps that you control — no coding is required. 9 * Version: 1.0. 410 * Stable tag: 1.0. 49 * Version: 1.0.5 10 * Stable tag: 1.0.5 11 11 * WC requires at least: 5.0 12 12 * WC tested up to: 6.7 … … 24 24 } 25 25 26 define( 'SHELFY_VERSION', '1.0. 4' );26 define( 'SHELFY_VERSION', '1.0.5' ); 27 27 define( 'SHELFY_MAIN_PLUGIN_FILE', __FILE__ ); 28 28 define( 'SHELFY_REQUIRED_WOOCOMMERCE_VERSION', '5.8.0' );
Note: See TracChangeset
for help on using the changeset viewer.