Skip to content

Conversation

@Huncsuga
Copy link
Contributor

Description

  • This PR fixes an issue where newly created product variants default their weight_unit to mm, which is a length unit and not a valid weight measurement.

  • When a product is created the weight unit, the system automatically assigns mm as the default value in the database. This leads to incorrect behavior in features that rely on weight-based logic, such as shipping calculations.

  • This change ensures that product variants use a valid weight unit by default.

Related Issue

Type

  • Bug fix

What was changed

  • Corrected the default value of weight_unit for product variants

  • Ensured the default unit represents a valid weight measurement (kg)

Expected Outcome

  • Newly created product variants no longer default to an invalid weight unit

  • Weight-based calculations (e.g. shipping) behave consistently

  • Data stored in the database correctly reflects weight semantics

How to test

  • Create a new product in the Lunar admin panel

  • Inspect the weight_unit value in the database

  • Verify that the unit defaults to a valid weight unit (e.g. kg) and not mm

$table->string('weight_unit')->default('kg')->nullable()->change();
});

DB::table($this->prefix . 'product_variants')
Copy link
Collaborator

Choose a reason for hiding this comment

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

We shouldn't be doing any data changes within migrations, instead use a state update class. See the database/state folder for how these are structured :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@alecritson Thanks for the PR comment! I’ve updated it.

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.

Product variant weight_unit defaults to mm instead of a valid weight unit

2 participants