Jump to content

Save product quantity to other field


gruszdaname

Recommended Posts

Hello,
I want to save order (ps_order_detail) product quantity (product_quantity) to other field in same table (product_quantity_order) for client to see original order qty he orderer.
I have module to edit quantity of existing order and to complete order for but client need to see what he ordered in first place.

I write function but it's not working.

    public function postProcess() {
        if (Tools::isSubmit('id_order')) {
            $orderId = (int)Tools::getValue('id_order');
            $op_qty = (int)Tools::getValue('product_quantity', array());

            $query = "UPDATE " . _DB_PREFIX_ . "order_detail SET product_quantity_order = '" . $op_qty . "' WHERE id_order=" . $orderId;
            $result = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS($query);
        }
        parent::postProcess();

    }


Any help please, Prestashop 1.6.1.17


I've try even smth like this:

 

class AdminOrdersController extends AdminOrdersControllerCore
{
// Complete module functions

[...]


    public function postProcess() {

        if (Tools::getValue('product_quantity')) {

            $id_ord = (int)Tools::getValue('id_order');
            $id_prod = (int)Tools::getValue('product_id');
            //$op_qty = (int)Tools::getValue('product_quantity', array());

            $quantity = (int)Tools::getValue('product_quantity');

            $query = "UPDATE `"._DB_PREFIX_."order_detail` od SET product_quantity_order=". $quantity . " WHERE od.id_order=" . $id_ord . " AND od.product_id=" . $id_prod . " AND od.id_shop=" . $id_shop . ";";

            Db::getInstance()->Execute($query);

        }
        parent::postProcess();
    }
}

But no luck :(

Edited by gruszdaname (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...