MacJ
MacJ

Reputation: 91

Prestashop - Change product quantity in the order module

I'm currently working on a few modules connected to a ERP system. I want to be able to update the product quantity after the client has made his buy. Does anyone have any insight on this? Will I have to override the core class?

Thank you in advance

Upvotes: 0

Views: 232

Answers (1)

MacJ
MacJ

Reputation: 91

Here is the solution to my own question. Feel free to write me if you have any questions.

public function modifyItemInOrder($order_id, $order_param)
{
    if ($order_id) {
        $order_detail = new OrderDetail($order_id);

        $order_detail->total_price_tax_incl             = $order_param->total_price_tax_incl;
        $order_detail->total_price_tax_excl             = $order_param->total_price_tax_excl;
        $order_detail->total_shipping_price_tax_incl    = $order_param->total_shipping_price_tax_incl;
        $order_detail->total_shipping_price_tax_excl    = $order_param->total_shipping_price_tax_incl;

        $order_detail->product_quantity                 = $order_param->product_quantity;
        $order_detail->update();
    }
}

Cheers

Upvotes: 1

Related Questions