Jump to content

Webservice POST order sets default values on id_carrier and current_state


MiquelGrau

Recommended Posts

Good morning,

 

When I call the webservice to create a new order (after creating a new cart) and I specify the id_carrier and current_state values it just sets the default values of these fields (not the ones that I specified).

 

The only solution that I found is using a PUT call right after the POST to set these values as I want, but still, that can't be the way to do it propertly.

 

Does anyone know any solution?

 

Thank you.

 

 

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

  • MiquelGrau changed the title to Webservice POST order sets default values on id_carrier and current_state

I found so many topics with this problem but none of them have provided any solution. So I guess I won't be an exception.

However, I think the problem might be in this file: classes/Order.php 

And the most of them have said something about this function:

public function addWs($autodate = true, $null_values = false)

    {

        /** @var PaymentModule $payment_module */

        $payment_module = Module::getInstanceByName($this->module);

        $customer = new Customer($this->id_customer);

        $payment_module->validateOrder($this->id_cart, Configuration::get('PS_OS_WS_PAYMENT'), $this->total_paid, $this->payment, null, array(), null, false, $customer->secure_key);

        $this->id = $payment_module->currentOrder;



        return true;

    }

 

But my problem is about id_carrier and current_states. I think, the first one has nothing to do with this function, but current_states could be fixed if we change something here. I don't know what could I change to fix it, though.

 

I hope somebody replies me. I even saw this problem in topics from 2016, so it's old. 

These are the topics that I found all of them with no solution:

 

Webservice order BUG - Bug reports - PrestaShop Forums

 

How set a state for an order at creation time ? - Core developers - PrestaShop Forums

 

WebService- Create order id_carrier value 0 · Issue #11945 · PrestaShop/PrestaShop · GitHub

Link to comment
Share on other sites

Good morning again,

 

This shouldn't be a solution, but doing this change now I get another current_state as default (the one that I actually want). The solution has to be not setting the values as default, just the values that you put in the post call. Anyway, here is what I changed.

public function addWs($autodate = true, $null_values = false)

    {

        /** @var PaymentModule $payment_module */

        $payment_module = Module::getInstanceByName($this->module);

        $customer = new Customer($this->id_customer);

        $payment_module->validateOrder($this->id_cart, Configuration::get('PS_OS_CHEQUE'), $this->total_paid, $this->payment, null, array(), null, false, $customer->secure_key);

        $this->id = $payment_module->currentOrder;



        return true;

    }

 

But I still have the problem on the id_carrier value. If someone could help me out I'd really appreciate it.

 

Thank's

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