Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update class.Cart.php #25

Merged
merged 1 commit into from
Oct 24, 2024
Merged

Conversation

nia-cloud-official
Copy link
Contributor

This update introduces several enhancements to the cart system, focusing on improving the user experience and adding functionality for discount codes, shipping costs, and persistent carts.

  1. Discount Feature

    Added functionality to apply a discount code to the cart, reducing the total price.
    Users can input a discount code, and the cart will automatically apply the discount to the total.
    New methods:
    applyDiscount($code, $amount): Applies the discount code and amount.
    getTotalWithDiscount(): Returns the total price after applying the discount.

  2. Shipping Costs

    Implemented a way to add shipping costs to the cart total.
    The shipping cost can be set manually, and it will be added to the total amount at checkout.
    New methods:
    setShippingCost($cost): Sets the shipping cost.
    getTotalWithShipping(): Returns the total cost after adding shipping.

  3. Persistent Cart for Logged-in Users

    Added the ability to save the cart data into a database for logged-in users.
    This allows users to maintain their cart items between sessions, ensuring a smoother shopping experience.
    New methods:
    saveToDatabase($userId): Saves the cart items to the database for the given user.
    loadFromDatabase($userId): Loads the cart from the database when the user logs in.

Bug Fixes

Refined the session writing and reading mechanism to ensure data integrity across different cart updates.
Improved the getTotalQuantity() and getTotalItem() methods to be more accurate when applying discounts and shipping costs.

@seikan seikan merged commit cae64d3 into seikan:master Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants