Plugin Directory

Changeset 2767893


Ignore:
Timestamp:
08/08/2022 02:10:01 PM (4 years ago)
Author:
shelfyio
Message:

v1.0.1 release

Location:
shelfy-mobile-commerce-platform
Files:
27 added
1 deleted
3 edited

Legend:

Unmodified
Added
Removed
  • shelfy-mobile-commerce-platform/trunk/README.txt

    r2767403 r2767893  
    1 === Shelfy - Mobile App Builder ===
     1=== Shelfy - Mobile App Builder - Dev ===
    22Contributors: itziksn
    33Tags: woocommerce, mobile, application, android, ios
    44Requires at least: 5.8
    55Tested up to: 6.0
    6 Stable tag: 1.0.0
     6Stable tag: 1.0.1
    77License: GPLv2 or later
    88License URI: http://www.gnu.org/licenses/gpl-2.0.html
  • shelfy-mobile-commerce-platform/trunk/includes/controllers/class-shelfy-cart-rest-api.php

    r2767340 r2767893  
    169169        $batch_response = array();
    170170        foreach ( $requests as $index => $request ) {
    171             $response = $this->update_item_quantity( $request );
     171            $response = $this->update_item_quantity( $request, true );
    172172            if ( is_wp_error( $response ) ) {
    173173                $batch_response[] = array(
     
    198198        $batch_errors = array();
    199199        foreach ( $products as $index => $product ) {
    200             $response = $this->update_item_quantity( $product );
     200            $response = $this->update_item_quantity( $product, true );
    201201            if ( is_wp_error( $response ) ) {
    202202                $batch_errors[] = array(
     
    220220     *
    221221     * @param WP_REST_Request $request The HTTP request object.
    222      */
    223     public function update_item_quantity( $request ) {
     222     * @param bool $add_always whether to always add the quantity requsted, regardless of whether the exact item present in the cart already.
     223     */
     224    public function update_item_quantity( $request, $add_always = false ) {
    224225        $product_id = $request['productId'];
    225226        $variant_id = $request['variantId'];
    226227        $quantity   = $request['quantity'];
     228        $attribues = array();
     229        if ( isset( $request['dynamicAttributes'] ) ) {
     230            $attribues['shelfy_dynamic_attributes'] = $request['dynamicAttributes'];
     231        }
    227232        $cart       = WC()->cart;
    228233        $product    = wc_get_product( $product_id );
     
    242247        }
    243248        $variations = wc_get_product_variation_attributes( $variant_id );
    244         $cart_id    = $cart->generate_cart_id( $product_id, $variant_id, $variations );
    245         $cart_id    = $cart->find_product_in_cart( $cart_id );
    246         if ( ! empty( $cart_id ) ) {
    247             $cart->set_quantity( $cart_id, $quantity );
     249        if ( !$add_always ) {
     250            $cart_id    = $cart->generate_cart_id( $product_id, $variant_id, $variations, $attribues );
     251            $cart_id    = $cart->find_product_in_cart( $cart_id );
     252        }
     253        if ( ! empty( $cart_id ) && ! $add_always ) {
     254            if ( 0.0 === (float)$quantity ) {
     255                $cart->remove_cart_item( $cart_id );
     256            } else {
     257                $cart->set_quantity( $cart_id, $quantity );
     258            }
    248259        } elseif ( $quantity > 0 ) {
    249260            try {
    250                 if ( ! $cart->add_to_cart( $product_id, $quantity, $variant_id ) ) {
     261                if ( ! $cart->add_to_cart( $product_id, $quantity, $variant_id, $variations, $attribues ) ) {
    251262                    $notices = WC()->session->get( 'wc_notices' );
    252263                    if ( $notices && isset( $notices['error'] ) ) {
     
    281292                'required' => false,
    282293            ),
     294            'dynamicAttributes' => array(
     295                'type'     => 'object',
     296                'required' => false,
     297            )
    283298        );
    284299    }
  • shelfy-mobile-commerce-platform/trunk/shelfy.php

    r2767401 r2767893  
    77 * Plugin Name:       Shelfy - Mobile App Builder
    88 * Description:       Build fast mobile apps that you control — no coding is required.
    9  * Version:           1.0.0
    10  * Stable tag:        1.0.0
     9 * Version:           1.0.1
     10 * Stable tag:        1.0.1
    1111 * WC requires at least: 5.0
    1212 * WC tested up to: 6.7
     
    2424}
    2525
    26 define( 'SHELFY_VERSION', '1.0.0' );
     26define( 'SHELFY_VERSION', '1.0.1' );
    2727define( 'SHELFY_MAIN_PLUGIN_FILE', __FILE__ );
    2828define( 'SHELFY_REQUIRED_WOOCOMMERCE_VERSION', '5.8.0' );
Note: See TracChangeset for help on using the changeset viewer.