Skip to content

Conversation

@gustaavik
Copy link
Member

This pull request introduces significant updates to the shipping, discount, order, and product use cases, including support for shipping methods, weight-based calculations, and enhanced discount logic. Key changes include the addition of shipping-related functionality, updates to discount application logic, and the inclusion of weight attributes for products and variants.

Shipping Functionality Enhancements:

  • Added a new ShippingUseCase to the OrderUseCase for handling shipping methods and costs. This includes calculating shipping options and applying shipping methods to orders. (internal/application/usecase/order_usecase.go) [1] [2] [3] [4]
  • Updated CreateOrderInput to include ShippingMethodID for specifying the desired shipping method during order creation. (internal/application/usecase/order_usecase.go)
  • Added logic to calculate total weight for orders and integrate shipping costs based on weight and total value. (internal/application/usecase/order_usecase.go) [1] [2]

Discount Logic Improvements:

  • Enhanced the ApplyDiscountToOrder method to support category-based discounts by dynamically determining eligible products from specified categories. (internal/application/usecase/discount_usecase.go)

Product and Variant Updates:

  • Added a Weight attribute to CreateProductInput, CreateVariantInput, and AddVariantInput to support weight-based shipping calculations. (internal/application/usecase/product_usecase.go) [1] [2] [3]
  • Updated product and variant creation methods to handle the new Weight attribute and ensure the product's weight is updated when the default variant changes. (internal/application/usecase/product_usecase.go) [1] [2]

Documentation:

  • Added a comprehensive docs/shipping_api_examples.md file containing example request and response bodies for public and admin shipping API endpoints, including workflows for creating shipping methods, zones, and rates. (docs/shipping_api_examples.md)

- Added ShippingZone entity with methods for creation, updating, and address validation.
- Introduced ShippingMethod and ShippingRate repositories for data access.
- Implemented PostgreSQL repositories for shipping methods, zones, and rates with CRUD operations.
- Created migrations for shipping methods, zones, and rates tables, including weight and value-based rates.
- Developed mock shipping use case for testing, including methods for retrieving shipping options and calculating costs.
…lculation

- Updated the IsApplicableToOrder method in the Discount entity to clarify category checks and their handling in the use case layer.
- Changed the ApplyDiscount method in the Order entity to use the discount method directly and simplified the discount amount calculation.
- Fixed parameter formatting in the ShippingRateRepository to ensure correct SQL parameter binding.
- Added a chore to the todo list for refactoring the final amount calculation in the Order entity.
@gustaavik gustaavik merged commit 0dafbc7 into development Apr 30, 2025
@gustaavik gustaavik deleted the add-shipping-system branch April 30, 2025 14:27
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