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

Orderstate stuck after shipping address modification #1197

Closed
martijnvdbrug opened this issue Oct 27, 2021 · 2 comments
Closed

Orderstate stuck after shipping address modification #1197

martijnvdbrug opened this issue Oct 27, 2021 · 2 comments
Assignees
Labels
type: bug 🐛 Something isn't working

Comments

@martijnvdbrug
Copy link
Collaborator

Describe the bug
Order gets stuck in Modifying state after changing the shipping-address, because of recalculated shipping price.

To Reproduce
Steps to reproduce the behavior:
Setup 2 shippingMethods, both use a custom eligibility checker to check the shippingAddress:

  • for the Netherlands: €5,-
  • for outside the Netherlands: €14,-
  1. Order an item in the shop
  2. uring checkout I set country to Netherlands, this results in shipping of €5,-
  3. Select shipping within the Netherlands
  4. The customer messages me 'Oops I meant Nepal'
  5. Go to the admin, click on Modify order > Edit shipping address > select Nepal > check 'recalculate shipping' > preview changes
  6. Now it says, price difference '-5', I guess because it removed the 'Shipping in NL' method, because its not elligible anymore.
  7. Select a payment to refund and click Confirm.
  8. The order now stays in Modyfying.
  9. Whenever I try to Cancel modification I am not allowed to transition it to any of the states in the popup.

Expected behavior
I would expect the order to return to 'Payment Settled'

Environment (please complete the following information):

  • @vendure/core version: v1.2.1
  • Nodejs version 14
  • Database (mysql/postgres etc): mysql

Additional context
The order now has 'pick-up' as shippingMethod, probably because the 'Shipping in Netherlands', is not elligible anymore.

Order returned by getOrder

{
  "data": {
    "order": {
      "id": "286",
      "createdAt": "2021-10-27T06:18:14.961Z",
      "updatedAt": "2021-10-27T06:31:28.000Z",
      "code": "QV3ZJ5YS8D3RHMAK",
      "state": "Modifying",
      "nextStates": [
        "PaymentAuthorized",
        "PaymentSettled",
        "PartiallyShipped",
        "Shipped",
        "PartiallyDelivered",
        "ArrangingAdditionalPayment"
      ],
      "active": false,
      "customer": {
        "id": "7",
        "firstName": "Martijn",
        "lastName": "van de Brug",
        "__typename": "Customer"
      },
      "lines": [
        {
          "id": "337",
          "featuredAsset": {
            "preview": "http://test-api.pinelab.studio/assets/preview/58/the-jaunt-book-008__02__preview.jpg",
            "__typename": "Asset"
          },
          "productVariant": {
            "id": "99",
            "name": "The Jaunt Tom Haugomat",
            "sku": "The Jaunt Tom Haugomat Edition",
            "trackInventory": "INHERIT",
            "stockOnHand": 9999997,
            "__typename": "ProductVariant"
          },
          "discounts": [],
          "unitPrice": 5505,
          "unitPriceWithTax": 6000,
          "proratedUnitPrice": 5505,
          "proratedUnitPriceWithTax": 6000,
          "quantity": 1,
          "items": [
            {
              "id": "731",
              "unitPrice": 5505,
              "unitPriceWithTax": 6000,
              "taxRate": 9,
              "refundId": null,
              "cancelled": false,
              "fulfillment": null,
              "__typename": "OrderItem"
            }
          ],
          "linePrice": 5505,
          "lineTax": 495,
          "linePriceWithTax": 6000,
          "discountedLinePrice": 5505,
          "discountedLinePriceWithTax": 6000,
          "__typename": "OrderLine"
        }
      ],
      "surcharges": [],
      "discounts": [],
      "promotions": [],
      "subTotal": 5505,
      "subTotalWithTax": 6000,
      "total": 5505,
      "totalWithTax": 6000,
      "currencyCode": "EUR",
      "shipping": 0,
      "shippingWithTax": 0,
      "shippingLines": [
        {
          "shippingMethod": {
            "id": "11",
            "code": "afhalen-in-leeuwarden",
            "name": "Afhalen in Leeuwarden",
            "fulfillmentHandlerCode": "my-parcel",
            "description": "",
            "__typename": "ShippingMethod"
          },
          "__typename": "ShippingLine"
        }
      ],
      "taxSummary": [
        {
          "description": "NL reduced",
          "taxBase": 5505,
          "taxRate": 9,
          "taxTotal": 495,
          "__typename": "OrderTaxSummary"
        },
        {
          "description": "shipping tax",
          "taxBase": 0,
          "taxRate": 9,
          "taxTotal": 0,
          "__typename": "OrderTaxSummary"
        }
      ],
      "shippingAddress": {
        "fullName": "martijn xxxx",
        "company": "-",
        "streetLine1": "xxx",
        "streetLine2": "xxx",
        "city": "xxxx",
        "province": null,
        "postalCode": "xxxxx",
        "country": "Nepal",
        "countryCode": "NP",
        "phoneNumber": "2432342342",
        "__typename": "OrderAddress"
      },
      "billingAddress": {
        "fullName": null,
        "company": null,
        "streetLine1": null,
        "streetLine2": null,
        "city": null,
        "province": null,
        "postalCode": null,
        "country": null,
        "countryCode": null,
        "phoneNumber": null,
        "__typename": "OrderAddress"
      },
      "payments": [
        {
          "id": "102",
          "createdAt": "2021-10-27T06:19:20.395Z",
          "transactionId": "tr_GckyFF7FTp",
          "amount": 6500,
          "method": "mollie-payment-demo",
          "state": "Settled",
          "nextStates": [
            "Cancelled"
          ],
          "errorMessage": null,
          "metadata": {
            "public": {
              "redirectLink": "https://www.mollie.com/checkout/select-method/xxxx"
            }
          },
          "refunds": [
            {
              "id": "11",
              "createdAt": "2021-10-27T06:31:28.244Z",
              "state": "Pending",
              "items": 0,
              "adjustment": 0,
              "total": 0,
              "paymentId": "102",
              "reason": "",
              "transactionId": null,
              "method": "mollie-payment-demo",
              "metadata": {},
              "orderItems": [],
              "__typename": "Refund"
            }
          ],
          "__typename": "Payment"
        }
      ],
      "fulfillments": [],
      "modifications": [
        {
          "id": "2",
          "createdAt": "2021-10-27T06:31:28.265Z",
          "isSettled": true,
          "priceChange": -500,
          "note": "",
          "payment": null,
          "orderItems": [],
          "refund": {
            "id": "11",
            "paymentId": "102",
            "total": 0,
            "__typename": "Refund"
          },
          "surcharges": [],
          "__typename": "OrderModification"
        }
      ],
      "__typename": "Order"
    }
  }
}
@martijnvdbrug martijnvdbrug added the type: bug 🐛 Something isn't working label Oct 27, 2021
@michaelbromley
Copy link
Member

Hi!
Looking into this now. What I don't understand is why the shipping would do to 0 once the domestic method becomes ineligible. What is supposed to happen is that the next cheapest eligible method is selected, see:

const results = await this.shippingCalculator.getEligibleShippingMethods(ctx, order, [
currentShippingMethod.id,
]);
if (results && results.length) {
const cheapest = results[0];
shippingLine.listPrice = cheapest.result.price;
shippingLine.listPriceIncludesTax = cheapest.result.priceIncludesTax;
shippingLine.shippingMethod = cheapest.method;
shippingLine.taxLines = [
{
description: 'shipping tax',
taxRate: cheapest.result.taxRate,
},
];
}

In your case, I am guessing the "pick up" method has a price of 0, which would cause it to be selected over the more expensive international method. Is that the case?

@martijnvdbrug
Copy link
Collaborator Author

@michaelbromley that is indeed the case! For me it's clear (and expected) that it defaults to pick-up

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug 🐛 Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants