Cart process
Prestashop Logic
Cart - Update item in cart
flowchart TD
Start[Start] --> CheckInput{Is quantity zero or product ID missing?}
CheckInput -- Yes --> InputError[Add error and exit]
CheckInput -- No --> LoadProduct[Load product]
LoadProduct --> ProductValid{Is product valid and accessible?}
ProductValid -- No --> ProductError[Add error and exit]
ProductValid -- Yes --> CheckCartQty[Check cart quantity]
CheckCartQty --> CalculateQty[Adjust quantity based on operation]
CalculateQty --> StockCheck{Is there enough stock?}
StockCheck -- No --> StockError[Add stock error and exit]
StockCheck -- Yes --> ModeCheck{Is mode add?}
ModeCheck -- No --> End[End]
ModeCheck -- Yes --> CartExists{Does cart exist?}
CartExists -- No --> CreateCart[Create a new cart]
CartExists --> CheckCustom[Are required custom fields filled?]
CheckCustom -- No --> CustomError[Add customization error and exit]
CheckCustom -- Yes --> UpdateQty[Call updateQty function]
UpdateQty --> QtyResult{Result of updateQty}
QtyResult -- Less than 0 --> MinQtyError[Show minimal quantity error]
QtyResult -- Equal to 0 --> MaxQtyError[Show max quantity error]
QtyResult -- Greater than 0 --> AllowRefreshCheck{Is allow refresh enabled?}
AllowRefreshCheck -- No --> SkipRefresh[Skip cart rule refresh]
AllowRefreshCheck -- Yes --> CompareRules[Compare cart rules]
CompareRules --> RulesChanged{Did cart rules change?}
RulesChanged -- Yes --> SetRefresh[Set ajax refresh to true]
RulesChanged -- No --> SkipRefresh
SkipRefresh --> AutoRemove[Auto remove cart rules]
AutoRemove --> AutoAdd[Auto add cart rules]
AutoAdd --> RulesRemoved{Were rules removed and refresh allowed?}
RulesRemoved -- Yes --> FinalRefresh[Set ajax refresh to true]
RulesRemoved -- No --> End
InputError --> End
ProductError --> End
StockError --> End
CustomError --> End
MinQtyError --> End
MaxQtyError --> End
Cart - Delete product from cart (Prestashop Logic)
flowchart TD
A["Start: Delete Cart Product Request"] --> B["Check for Other Customizations of Same Product"]
B --> C{"Other Customizations Exist?"}
C -- No --> G["Proceed to Delete Product"]
C -- Yes --> D["Get Minimal Quantity of Product or Attribute"]
D --> E["Sum Quantities of Other Customizations"]
E --> F{"Total Quantity >= Minimal Required?"}
F -- No --> Z["Return AJAX Error: Not Enough Quantity"]
F -- Yes --> G
G --> H{"Product Successfully Deleted?"}
H -- No --> END["Exit"]
H -- Yes --> I["Trigger actionAfterDeleteProductInCart Hook"]
I --> J{"Is Cart Now Empty?"}
J -- Yes --> K["Reset Delivery Option and Gift Info"]
J -- No --> L["Skip Reset"]
K --> M["Update Cart"]
L --> M
M --> N["Remove Invalid Cart Rules"]
N --> O["Add Applicable Cart Rules"]
O --> P{"Cart Rules Removed and allow_refresh = true?"}
P -- Yes --> Q["Set ajax_refresh = true"]
P -- No --> END
Q --> END
Z --> END