Skip to content

Commit

Permalink
Shopping cart performance enhancements (#6011)
Browse files Browse the repository at this point in the history
* Shopping cart performance enhancements

Reformatting
    - Use null coalescing (??) operator where indicated
    - Use short array syntax
    - No one-line conditionals
    - No one-line multiple assignments
Refactoring
    - Since the `contents` property is keyed on a 'uprid', change the `$products_id` key to be `$uprid` on foreach traversals of that array.
    - Limit MySQL updates to a single row for unique operations.
    - Use `===` where warranted.
    - Use `zen_define_default` where warranted.
    - Use `strpos` instead of `preg_match` when checking for gift-certificates in the cart.
    - Remove redundant code.
    - Use `zen_get_product_details` where warranted to get maximum cached queries.  Results in a roughly 50% reduction in time taken to add/remove/update a product as well as the cart's overall calculations!
Corrections
    - `calculate` didn't process a 'base' product pricing if a product wasn't found, but *did* process the attributes!  Should the product be removed from the cart if this condition is found?

* Updating based on review comments
  • Loading branch information
lat9 committed Oct 18, 2023
1 parent ef4935c commit 636d4a3
Showing 1 changed file with 1,073 additions and 997 deletions.

0 comments on commit 636d4a3

Please sign in to comment.