/
Unfulfillable Order Cancellation missing details Issue Fix

Unfulfillable Order Cancellation missing details Issue Fix

What is the purpose of this article?

The purpose of this article is to fix the below two issues occurring on the workspace

  1. For unfulfillable orders, cancellation Type, Reason, SubReason and Additional remarks are not getting saved in Algolia.

  2. The cancellation type getting saved is incorrect in some cases.

This document will thoroughly discuss the logic and technical implementation to fix this issue.

Current Implementation

  1. Whenever the Algolia sync Api is called through the task queue, it accepts the order item ids (primary keys) as the request parameters

    Api type and path - POST algolia/sync/orderItemIds (order return service) repository - esb client order return gcp project - eshopbox-client-portal-prod API Curl curl --location 'https://order-return-dot-eshopbox-client-portal-prod.appspot.com/_ah/api/esb/v2/algolia/sync/orderItemIds' \ --header 'Content-Type: application/json' \ --data '{ "data": "[31351372, 31351577, 31359295, 31362715]" }'
  2. Now fetch all the details required to be synced in Algolia by the order items ids (primary keys)

  3. Prepare an Algolia model Object

  4. Write the logic to set the details in the algolia model Object (e.g., logic for order status, current status, cancellation etc.)

  5. Once the details are set in the Algolia model Object. Update the object in algolia

The logic for Order Cancellation details to be set in Algolia

  1. If shipment_status_logs is empty, then simply return else
    {

    1. Iterate over the shipmentLogs

    2. check if the status is cancelled,
      a. Check if the remark contains "fulfillment_cancel" then set the cancellationType as seller
      b. If the remark does not contain "fulfillment_cancel" then set the cancellationType as customer
      c. Get cancellationReason from order_items table.
      1. if cancellationReason contains two reasons separated by comma then set First reason as cancellationReason and second reason as cancellationSubReason
      2. if cancellationReason contains only one reason then then set it as cancellationReason
      d. Get remark from order_items table.If the remarks is not empty or null then set it in Additional remarks

}

issue with the current implementation :-

  1. For unfulfillable orders, cancellation Type, Reason, SubReason and Additional remarks are not getting saved in Algolia.

  2. The cancellation type getting saved is incorrect in some cases.

  3. Below are the issues mentioned in detail in table format

cancellation reason

what is shown on workspace as per current implementation in cancelled By

Expected (cancelled By)

cancellation reason

what is shown on workspace as per current implementation in cancelled By

Expected (cancelled By)

Item unavailable

Customer

Seller

Other

customer

Seller

Not able to service by shipping partner

customer

Seller

Flagged as Fraudulent order

customer

Customer

Order shipped from another location

customer

Customer

Customer requested

Customer

Customer

Technical steps to achieve the new task

This logic is for any single order item syncing in algolia.

  1. check if the status is cancelled. i.e., status column of order_items table contains the value “CANCELLED“

  2. If false then return

  3. Store all the 3 reasons of customer cancellation in constants.java in a String variable.

  4. Get cancellation reason from cancellationReason column of order_items table and store it in a String variable named cancellationReason.

    1. If cancellationReason contains comma, then split it by comma

      1. Set the 0th array index as cancellation reason

      2. Set the 1th array index as cancellation sub reason

    2. if cancellationReason does not contains comma,

      1. Set it as cancellation reason directly

    3. Check if the reasons in constants contains cancellationReason

      1. If true, set cancellation type as “customer“ else “seller“

    4. Get the detail of remark column of order_items table

      1. If the remark is not null or emprt, then set it as additional remarks

Add label

Related content