Jump to content

[SOLVED] How to disallow customers return their products in one order while in shipped status?


Ali Samie

Recommended Posts

While prestashop provides a page for order settings and specially for order status setting, it does no work as expected.
We want our customers to return their products only if it is "Delivered", so I opened order status settings page in back office, and saw that for "Shipped" status we have the "Delivery" flag as active. I disabled this but again when an order is in this status, customer can return products of the order, even they are not arrived and delivered yet!

This is the current order status settings

image.thumb.png.19ec7aad87a405b0dac60e5647fe743f.png

 

This is the current order details page which you can see customer can return productsimage.thumb.png.5868c5207042298a43a84a41b78c3014.png

Link to comment
Share on other sites

2 minutes ago, Nickz said:

I think you will need someoutside data to accomplish that. The shipping service has that.

what do you mean by outside data? like another table? or modification?

I think this should already work with the prestashop order status settings.

in template file of the order return, there is a flag with this key "is-returnable", which means what it says. But when you look anlt the result, it doesn't work properly

Link to comment
Share on other sites

9 hours ago, bera_ramazan said:

please edit

themes/x/templates/custumer/_partials/order-detail-return.tpl

add this code

{if $order.history.current.id_order_state == 5}
XXX
{/if}

add these if columns to the field you want to hide

Thank you this is a quick fix.

I see that this issue happens here in this file
src/Adapter/Presenter/Order/OrderDetailLazyArray.php

    /**
     * Can this order be returned by the client?
     *
     * @return bool
     */
    public function isReturnable()
    {
        if (Configuration::get('PS_ORDER_RETURN', null, null, $this->id_shop) && $this->isPaidAndShipped()) {
            return $this->getNumberOfDays();
        }

        return false;
    }

I should apply a fix to this method I guess

Link to comment
Share on other sites

I fixed it with an override in a custom module
Here is the override

<?php

class Order extends OrderCore
{
    /**
     * Can this order be returned by the client?
     *
     * @return bool
     */
    public function isReturnable()
    {
        return $this->isDelivered()
            && parent::isReturnable();
    }

    /**
     * Checks if the current order status is delivered.
     *
     * @return bool
     */
    public function isDelivered()
    {
        $order_state = $this->getCurrentOrderState();
        if ($order_state->delivery) {
            return true;
        }
        return false;
    }
}

 

Link to comment
Share on other sites

  • Ali Samie changed the title to [SOLVED] How to disallow customers return their products in one order while in shipped status?

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...