saleor / saleor-storefront

A GraphQL-powered, NextJs-based, PWA storefront for Saleor. IMPORTANT: This project is [DEPRECATED] in favor of saleor/react-storefront soon to become our default demo and storefront starter pack.
https://demo.saleor.io/
BSD 3-Clause "New" or "Revised" License
768 stars 674 forks source link

Items removed from cart being sent at checkout #1020

Open dsychin opened 3 years ago

dsychin commented 3 years ago

What I'm trying to achieve

Checkout successfully.

Steps to reproduce the problem

  1. Add item to cart.
  2. Make item run out of stock.
  3. Remove item from cart or delete item.
  4. Add some other item.
  5. Checkout.
  6. Submit address.
  7. Checkout error but no visual feedback.

What I expected to happen

Request

{
    "0": {
        "operationName": "CreateCheckout",
        "query": "fragment Price on TaxedMoney {\n  gross {\n    amount\n    currency\n    __typename\n  }\n  net {\n    amount\n    currency\n    __typename\n  }\n  __typename\n}\n\nfragment ProductVariant on ProductVariant {\n  id\n  name\n  sku\n  quantityAvailable\n  isAvailable\n  pricing {\n    onSale\n    priceUndiscounted {\n      ...Price\n      __typename\n    }\n    price {\n      ...Price\n      __typename\n    }\n    __typename\n  }\n  attributes {\n    attribute {\n      id\n      name\n      __typename\n    }\n    values {\n      id\n      name\n      value: name\n      __typename\n    }\n    __typename\n  }\n  product {\n    id\n    name\n    thumbnail {\n      url\n      alt\n      __typename\n    }\n    thumbnail2x: thumbnail(size: 510) {\n      url\n      __typename\n    }\n    productType {\n      id\n      isShippingRequired\n      __typename\n    }\n    __typename\n  }\n  __typename\n}\n\nfragment CheckoutLine on CheckoutLine {\n  id\n  quantity\n  totalPrice {\n    ...Price\n    __typename\n  }\n  variant {\n    ...ProductVariant\n    __typename\n  }\n  __typename\n}\n\nfragment Address on Address {\n  id\n  firstName\n  lastName\n  companyName\n  streetAddress1\n  streetAddress2\n  city\n  postalCode\n  country {\n    code\n    country\n    __typename\n  }\n  countryArea\n  phone\n  isDefaultBillingAddress\n  isDefaultShippingAddress\n  __typename\n}\n\nfragment ShippingMethod on ShippingMethod {\n  id\n  name\n  price {\n    currency\n    amount\n    __typename\n  }\n  __typename\n}\n\nfragment PaymentGateway on PaymentGateway {\n  id\n  name\n  config {\n    field\n    value\n    __typename\n  }\n  currencies\n  __typename\n}\n\nfragment Checkout on Checkout {\n  token\n  id\n  totalPrice {\n    ...Price\n    __typename\n  }\n  subtotalPrice {\n    ...Price\n    __typename\n  }\n  billingAddress {\n    ...Address\n    __typename\n  }\n  shippingAddress {\n    ...Address\n    __typename\n  }\n  email\n  availableShippingMethods {\n    ...ShippingMethod\n    __typename\n  }\n  shippingMethod {\n    ...ShippingMethod\n    __typename\n  }\n  shippingPrice {\n    ...Price\n    __typename\n  }\n  lines {\n    ...CheckoutLine\n    __typename\n  }\n  isShippingRequired\n  discount {\n    currency\n    amount\n    __typename\n  }\n  discountName\n  translatedDiscountName\n  voucherCode\n  availablePaymentGateways {\n    ...PaymentGateway\n    __typename\n  }\n  __typename\n}\n\nfragment CheckoutError on CheckoutError {\n  code\n  field\n  message\n  __typename\n}\n\nmutation CreateCheckout($checkoutInput: CheckoutCreateInput!) {\n  checkoutCreate(input: $checkoutInput) {\n    errors: checkoutErrors {\n      ...CheckoutError\n      __typename\n    }\n    checkout {\n      ...Checkout\n      __typename\n    }\n    __typename\n  }\n}\n",
        "variables": {
            "checkoutInput": {
                "email": "admin@example.com",
                "lines": [
                    {
                        "quantity": 1,
                        "variantId": "UHJvZHVjdFZhcmlhbnQ6MQ=="
                    },
                    {
                        "quantity": 0,
                        "variantId": "UHJvZHVjdFZhcmlhbnQ6Mg=="
                    },
                    {
                        "quantity": 0,
                        "variantId": "UHJvZHVjdFZhcmlhbnQ6NQ=="
                    }
                ],
                "shippingAddress": {
                    "city": "RERUM VOLUPTATE AUTE",
                    "companyName": "Moses and Larson Plc",
                    "country": "BN",
                    "countryArea": "",
                    "firstName": "Ronan",
                    "lastName": "Tran",
                    "phone": "+6738111111",
                    "postalCode": "BB1234",
                    "streetAddress1": "802 Old Parkway",
                    "streetAddress2": "Voluptate officiis e"
                }
            }
        }
    }
}

Response (200 OK)

This is the response when the item has been deleted. It will should insufficient stock error if item has no stock, even though the quantity in cart is 0.

{
    "0": {
        "errors": [
            {
                "message": "There is no node of type ProductVariant with pk 2",
                "locations": [
                    {
                        "line": 187,
                        "column": 3
                    }
                ],
                "path": [
                    "checkoutCreate"
                ],
                "extensions": {
                    "exception": {
                        "code": "AssertionError"
                    }
                }
            }
        ],
        "data": {
            "checkoutCreate": null
        }
    }
}

System information Operating system: Windows 10 Browser: Firefox

gorjan-mishevski commented 3 years ago

Did someone manage to find how to fix this? Basically the whole delete process is broken and a returning user checkout is broken aswell. Because after a delete of a product, every time you add another product saleor brings back the old ones with quantity 0. Basically the user is unable to buy another product after he deletes an item. This is a major issue. Resulting in a state that the user is unable to complete a checkout.

EDIT: PR fix here https://github.com/mirumee/saleor-sdk/pull/109