Plugin Directory

Changeset 3364556


Ignore:
Timestamp:
09/19/2025 01:01:58 PM (7 months ago)
Author:
printess
Message:

Fixed improper handling of cart item sorting for some users that have cart items that are not printess cart items and have object type cart items instead of array type cart items

Location:
printess-editor/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • printess-editor/trunk/printess.php

    r3364022 r3364556  
    55 * Plugin URI: https://printess.com/kb/integrations/woo-commerce/index.html
    66 * Developer: Bastian Kröger (support@printess.com); Alexander Oser (support@printess.com)
    7  * Version: 1.6.63
     7 * Version: 1.6.64
    88 * Author: Printess
    99 * Author URI: https://printess.com
     
    1414 * Tested up to: 6.8
    1515 *
    16  * Woo: 10000:924021dfsfhsf8429842386wdff234sfd
     16 * Woo: 10000:924022dfsfhsf8429842386wdff234sfd
    1717 * WC requires at least: 5.8
    1818 * WC tested up to: 9.8.2
     
    22632263            $sorted_cart_contents,
    22642264            function ( $a, $b ) {
    2265                 if ( array_key_exists( 'printess_date_added', $a ) && array_key_exists( 'printess_date_added', $b ) ) {
    2266                     return strcmp( $a['printess_date_added'], $b['printess_date_added'] ) * -1;
    2267                 } elseif ( array_key_exists( 'printess_date_added', $a ) && ! array_key_exists( 'printess_date_added', $b ) ) {
     2265                $a_date = null;
     2266                $a_id = null;
     2267                $b_date = null;
     2268                $b_id = null;
     2269
     2270                if(is_array($a)) {
     2271                    if(array_key_exists('printess_date_added', $a)) {
     2272                        $a_date = $a['printess_date_added'];
     2273                    }
     2274
     2275                    if(array_key_exists('id', $a)) {
     2276                        $a_id = $a['id'];
     2277                    }
     2278                } else if(is_object($a)) {
     2279                    if(property_exists($a, 'printess_date_added')) {
     2280                        $a_date = $a->printess_date_added;
     2281                    }
     2282
     2283                    if(property_exists($a, 'id')) {
     2284                        $a_id = $a->id;
     2285                    }
     2286                }
     2287
     2288                if(is_array($b)) {
     2289                    if(array_key_exists('printess_date_added', $b)) {
     2290                        $b_date = $b['printess_date_added'];
     2291                    }
     2292
     2293                    if(array_key_exists('id', $b)) {
     2294                        $b_id = $b['id'];
     2295                    }
     2296                } else if(is_object($b)) {
     2297                    if(property_exists($b, 'printess_date_added')) {
     2298                        $b_date = $b->printess_date_added;
     2299                    }
     2300
     2301                    if(property_exists($b, 'id')) {
     2302                        $b_id = $b->id;
     2303                    }
     2304                }
     2305
     2306                if ( null !== $a_date && null !== $b_date ) {
     2307                    return strcmp( $a_date, $b_date ) * -1;
     2308                } elseif ( null !== $a_date && null === $b_date ) {
    22682309                    return -1;
    2269                 } elseif ( ! array_key_exists( 'printess_date_added', $a ) && array_key_exists( 'printess_date_added', $b ) ) {
     2310                } elseif ( null === $a_date && null !== $b_date ) {
     2311                    return 1;
     2312                }  else if ( null !== $a_id && null !== $b_id ) {
     2313                    return $b_id - $a_id;
     2314                } elseif ( null !== $a_id && null === $b_id ) {
     2315                    return -1;
     2316                } elseif ( null === $a_id && null !== $b_date ) {
    22702317                    return 1;
    22712318                } else {
    2272                     $a_id = -1;
    2273                     $b_id = -1;
    2274 
    2275                     if(property_exists($a, "id")) {
    2276                         $a_id = $a->id;
    2277                     } else if(is_array($a) && array_key_exists("id", $a)) {
    2278                         $a_id = $a["id"];
    2279                     } else {
    2280                         //Give up and sort it at the end
    2281                         return 1;
    2282                     }
    2283 
    2284                     if(property_exists($b, "id")) {
    2285                         $a_id = $a->id;
    2286                     } else if(is_array($b) && array_key_exists("id", $b)) {
    2287                         $b_id = $b["id"];
    2288                     } else {
    2289                         //Give up and sort it at the end
    2290                         return -1;
    2291                     }
    2292 
    2293                     return $sort_order[ $a_id ] < $sort_order[ $b_id ] ? -1 : 1;
     2319                    return 0;
    22942320                }
    22952321            }
    22962322        );
     2323    } catch(\InvalidArgumentException $ex) {
     2324        $sorted_cart_contents = $cart_contents;
    22972325    } catch( \Exception $ex) {
    22982326        $sorted_cart_contents = $cart_contents;
    2299     }
    2300 
    2301     $index              = 0;
     2327    } catch (TypeError $e) {
     2328        $sorted_cart_contents = $cart_contents;
     2329    } catch (Throwable $e) {
     2330        $sorted_cart_contents = $cart_contents;
     2331    }
     2332
     2333        $index              = 0;
    23022334    $sort_order_changed = false;
    23032335
  • printess-editor/trunk/readme.txt

    r3364022 r3364556  
    335335- Fixed parsing of serialized json configuration for merge templates in case a json string was provided as merge template name
    336336- Fixed css for saving overlay thats displayed during saving a design to the customer account.
     337
     338= 1.6.64 =
     339- Fixed improper handling of cart item sorting for some users that have cart items that are not printess cart items and have object type cart items instead of array type cart items
Note: See TracChangeset for help on using the changeset viewer.