Jump to content

Merchandise Return auto change order status?


c64girl

Recommended Posts

17 hours ago, Knowband Plugins said:

Sorry the requested changes is not provided by the Prestashop default, as the order status doesnt changes.

That can on be possible after making changes in core files.

You can hire a developer for the same who can customize this by modifying the code code for you.

I am not asking it is possible by default. I know its not. I am asking if someone done that changes and can share how to.

Link to comment
Share on other sites

You can add the below code in "controllers\admin\AdminReturnController.php" , postProcess(),  above"if (Tools::isSubmit('submitAddorder_returnAndStay')) {"

Code need to added

$kb_order_obj = new Order($orderReturn->id_order);
$history = new OrderHistory();

$history->id_order = $kb_order_obj->id;
$history->id_employee = (int) $this->context->employee->id;
$use_existings_payment = false;
if (!$kb_order_obj->hasInvoice()) {
    $use_existings_payment = true;
}
$history->changeIdOrderState((int) Configuration::get('PS_OS_CANCELED'), $kb_order_obj, $use_existings_payment);                         //code to update the order status to "Cancelled" Note that the whole order is treated as cancelled
$carrier = new Carrier($kb_order_obj->id_carrier, $kb_order_obj->id_lang);
$templateVars = array();
if ($history->id_order_state == Configuration::get('PS_OS_SHIPPING') && $kb_order_obj->shipping_number
) {
    $templateVars = array(
        '{followup}' => str_replace('@', $kb_order_obj->shipping_number, $carrier->url)
    );
}

// Save all changes
if ($history->addWithemail(true, $templateVars)) {                                                                                //Code to send the respective mails for cancelled order to customer
    // synchronizes quantities if needed..
    if (Configuration::get('PS_ADVANCED_STOCK_MANAGEMENT')) {                                                 
        foreach ($kb_order_obj->getProducts() as $product) {
            if (StockAvailable::dependsOnStock($product['product_id'])) {
                StockAvailable::synchronize(
                    $product['product_id'],
                    (int) $product['id_shop']
                );
            }
        }
    }
}

Link to comment
Share on other sites

One more question. Is it possible to somehow modify the code to automatically change the status in Merchandise Return to Waiting for package? As soon as the customer sets the merchandise return? Of course, along with this would go changing the status of the customer to cancelled.

Edited by c64girl (see edit history)
Link to comment
Share on other sites

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...