Request Order Cancellation Feature From Vendor Panel

Hi there,

We're trying to implement the option to request an order cancelation from the vendor panel in the view orders page. The idea is to rely on order status change : when the vendor clicks on the request cancelation button, the order status changes to await cancelation status … in the admin panel, we add an order tab in the moderation menu, that page will only display the orders with the await cancelation status, the admin can either approve the cancelation or deny it, both actions will also change the order status: Cancelled if approved or previous status before cancelation request if denied.

Now the question is : After adding the button like shown below in design/backend/templates/views/orders/manage.tpl

{if $runtime.company_id}
  • {btn type="list" href="" text={__("request_cancellation")}}
  • {/if}

    I need to call the order_status_change API to change the order status to await cancelation: something like this: used in the delete order button

    href="orders.delete?order_id=`$o.order_id`&redirect_url=`$current_redirect_url`"
    

    Any ideas on how to do it ?

    Thanks

    Please try

    orders.update_status?id=`$o.order_id`&status=I

    Please try

    orders.update_status?id=`$o.order_id`&status=I

    Hello,

    Thanks for the answer, I tried calling the API this way, but I get a 404 not found message after clicking on the request cancellation as shown in the screenshots below.

    02.png

    Hello,

    Thanks for the answer, I tried calling the API this way, but I get a 404 not found message after clicking on the request cancellation as shown in the screenshots below.

    The update_status mode of the orders dispatch accepts only POST requests, GET requests will result in 404 page.

    Hello,

    Thanks for the answer, I tried calling the API this way, but I get a 404 not found message after clicking on the request cancellation as shown in the screenshots below.

    Add cm-post class to your link

    Add cm-post class to your link

    The status change is working, but the button redirects me to a blank page, can I add an option to reload the same page after the status change?


    The update_status mode of the orders dispatch accepts only POST requests, GET requests will result in 404 page.

    Thanks for the input, adding the cm-post class fixed the issue.

     {$current_redirect_url=$config.current_url|escape:url}
     
  • {btn type="list" href="orders.update_status?id=`$o.order_id`&status=A&redirect_url=`$current_redirect_url`" class="cm-post" text={__("request_cancellation")} method="POST"}
  • This was my attempt but it's not working.

    Try to replace

    redirect_url=

    with

    return_url=

    Try to replace

    redirect_url=

    with

    return_url=

    Thanks, that works.

    You are welcome!

    You are welcome!

    Hi again,

    I have a followup question regarding this feature, as I mentioned the idea is that the admin can see a list contains the orders that the vendor requested to be deleted.

    I created an add-on to add the Request deletion item in the vendor's menu as shown in the screenshot, I created a new .tpl file called cancellation in the design/backend/templates/ views/orders/cancellation.tpl

    Can you suggest an idea on how to filter the orders, I need to show the ones with the new status that I created ?

    In the cancellation.tpl, I tried copying the design/backend/templates/ views/orders/manage.tpl just to check if I can reach the orders data but it's show the page with no data available.

    E1.png

    E2.png

    E3.png

    E4.png

    E5.png

    You should also call fn_get_orders function ( check in the app/controllers/backend/orders.php file). You can also add the status parameter to it to receive order with specific order status only

    You should also call fn_get_orders function ( check in the app/controllers/backend/orders.php file). You can also add the status parameter to it to receive order with specific order status only

    Thanks for the input, I can't get the orders data using the same logic in design/backend/templates/views/orders/manage.tpl … You can see that I debugged the $orders variable in the design/backend/templates/views/orders/cancellation.tpl, but I get nothing.


    I'm not sure what's the issue here.

    ERR11.png

    ERR22.png

    At first, you should call the fn_get_orders function in the orders.post.php controller for the cancellation mode

    At first, you should call the fn_get_orders function in the orders.post.php controller for the cancellation mode

    I did that and now I have all the orders in the cancellation.tpl, I renamed it to cancel now.
    Can you show me how to add the status filter in the fn_get_orders function ?

    ERR33.png

    I was able to filter by adding this line before the fn_get_orders function :

     $params['status'] = 'A';
    

    I just need to remove the links in the table now, should be good to go.

    Thanks a lot for the assistance.

    I just need to remove the links in the table now, should be good to go.

    What kind of links do you mean?

    What kind of links do you mean?

    I mean the links where you click on the order ID or customer name to check the details, we decided to keep them since the admin needs to check the order's details before approving or denying the cancellation.

    I'm currently trying to find a way to block the vendor from requesting cancellation if the cancellation was denied once by the admin.

    I could also improve the UI like shown in the second screenshot using the thumbs up and down.

    I'm opened to any suggestions on how to do it.

    Thanks again.

    TEST.png

    TEST2.png

    TEST3.png

    I suggest you to add new column to the cscart_orders table to mark orders with denied cancellations