Plugin Directory

Changeset 2821499


Ignore:
Timestamp:
11/21/2022 12:06:07 PM (3 years ago)
Author:
shelfyio
Message:

1.0.5 added api to clean and update

Location:
shelfy-mobile-commerce-platform/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • shelfy-mobile-commerce-platform/trunk/includes/controllers/class-shelfy-cart-rest-api.php

    r2786898 r2821499  
    109109                'methods'             => WP_REST_Server::EDITABLE,
    110110                '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' ),
    111127                'permission_callback' => '__return_true',
    112128                'args'                => array(
     
    188204    public function batch_update_item_quantity( $request ) {
    189205        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();
    190234        $requests       = $request['products'];
    191235        $batch_response = array();
  • shelfy-mobile-commerce-platform/trunk/shelfy.php

    r2786898 r2821499  
    55 * @package Shelfy plugin
    66 * @wordpress-plugin
    7  * Plugin Name:       Shelfy - Mobile App Builder - Dev
     7 * Plugin Name:       Shelfy - Mobile App Builder
    88 * Description:       Build fast mobile apps that you control — no coding is required.
    9  * Version:           1.0.4
    10  * Stable tag:        1.0.4
     9 * Version:           1.0.5
     10 * Stable tag:        1.0.5
    1111 * WC requires at least: 5.0
    1212 * WC tested up to: 6.7
     
    2424}
    2525
    26 define( 'SHELFY_VERSION', '1.0.4' );
     26define( 'SHELFY_VERSION', '1.0.5' );
    2727define( 'SHELFY_MAIN_PLUGIN_FILE', __FILE__ );
    2828define( 'SHELFY_REQUIRED_WOOCOMMERCE_VERSION', '5.8.0' );
Note: See TracChangeset for help on using the changeset viewer.