Skip to content

Conversation

@Huncsuga
Copy link
Contributor

@Huncsuga Huncsuga commented Dec 14, 2025

Description

  • This PR fixes an issue where weight-based shipping rates ignore or inconsistently apply pricing breakpoints due to mismatched weight units during comparison.

  • When a Shipping Method is configured with Charge By: Weight, the cart’s total weight and the pricing break min_quantity values are not normalized to the same unit. As a result, defined Shipping Breakdowns (tiers) are skipped and the base price is often returned regardless of the actual cart weight.

  • This change ensures that both values are compared using a consistent weight unit, allowing pricing breakpoints to be evaluated correctly.

Related Issue

Fixes #2381

Type

Bug fix

What was changed

  • Normalized weight unit handling when evaluating shipping rate pricing breaks

  • Removed incorrect scaling (×100) applied when saving weight-based pricing break values

  • Ensured pricing break thresholds are stored and evaluated using the same unit as cart weight calculations

Expected Outcome

  • Weight-based shipping tiers are applied correctly as cart weight increases

  • Pricing breaks behave consistently regardless of the product’s configured weight unit (g / kg / lbs)

How to test

  1. Create a Shipping Method with Charge By: Weight
  2. Assign the Shipping Method to a Zone
  3. Create a Shipping Rate with multiple weight-based pricing breaks (e.g. 5, 10)
  4. Create two product variants:
    • Variant A: weight = 2 kg
    • Variant B: weight = 1500 g
  5. Add the following items to the cart:
    • 1 × Variant A (2 kg)
    • 3 × Variant B (3 × 1500 g = 4.5 kg)
  6. Verify that the shipping rate correctly evaluates the total cart weight (6.5 kg)
  7. Confirm that the appropriate pricing tier is applied based on the combined weight

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes a bug where weight-based shipping rate breakpoints were evaluated incorrectly due to inconsistent weight unit handling. The fix ensures cart weights and pricing tier thresholds are normalized to kilograms before comparison, allowing weight-based shipping tiers to apply correctly.

Key Changes:

  • Normalized all weight calculations to kilograms using the Converter facade
  • Removed incorrect scaling factor (×100) when saving and loading weight-based pricing breakpoints
  • Added UI helper text and suffix to clarify that weight thresholds should be entered in kg

Reviewed changes

Copilot reviewed 5 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
packages/table-rate-shipping/src/Drivers/ShippingMethods/ShipBy.php Converts product weights to kg before calculating total cart weight
packages/table-rate-shipping/src/Filament/Resources/ShippingZoneResource/Pages/ManageShippingRates.php Removes ×100 scaling for weight values and adds kg suffix/helper text to form field
packages/table-rate-shipping/resources/lang/en/relationmanagers.php Adds English helper text indicating weight should be entered in kg
packages/table-rate-shipping/resources/lang/ro/relationmanagers.php Adds Romanian helper text indicating weight should be entered in kg
packages/table-rate-shipping/resources/lang/hu/relationmanagers.php Adds Hungarian helper text indicating weight should be entered in kg

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

Weight-based Shipping Rates ignore pricing breakpoints due to inconsistent weight unit handling

1 participant