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

OrderLine expects a not null "identifier" (even if sku requirement is disabled) #254

Open
armezit opened this issue Apr 2, 2022 · 0 comments
Labels
0.x bug Something isn't working
Milestone

Comments

@armezit
Copy link
Contributor

armezit commented Apr 2, 2022

  • GetCandy version: 2.0-beta11
  • Laravel Version: 9.3.1
  • PHP Version: 8.1.2
  • Database Driver & Version:

Expected Behaviour:

The configuration in config/getcandy-hub/products.php lets us disable sku requirement.

https://github.com/getcandy/getcandy/blob/9bd91d7677759a540856f376ea8d757a3ea4a18e/packages/admin/config/products.php#L26-L29

Disabling sku should disable it's requirement in all places.

Actual Behaviour:

It works fine while saving product variants, but if you try to create an order which contains a product variant without sku, then an exception throws:

    "message": "SQLSTATE[23000]: Integrity constraint violation: 1048 Column 'identifier' cannot be null (SQL: insert into `order_lines` (`purchasable_type`, `purchasable_id`, `type`, `description`, `option`, `identifier`, `unit_price`, `unit_quantity`, `quantity`, `sub_total`, `discount_total`, `tax_breakdown`, `tax_total`, `total`, `notes`, `meta`, `order_id`, `updated_at`, `created_at`) values (...))",
    "exception": "Illuminate\\Database\\QueryException",
    ...

ProductVariant::getIdentifier() returns sku (which is null in this case):
https://github.com/getcandy/getcandy/blob/9bd91d7677759a540856f376ea8d757a3ea4a18e/packages/core/src/Actions/Carts/CreateOrder.php#L81

But order_lines.identifier column is not nullable.

Steps To Reproduce:

  1. disable sku requirement in config/getcandy-hub/products.php
  2. create a product variant without sku
  3. add the product variant to cart
  4. create order on cart
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
0.x bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants