Jump to content

Set Order Status


mertakdeniz

Recommended Posts

Hey there,

 

I wrote a module which is for subscription and I override some controllers. On my OrderController : 

$payment_module = Module::getInstanceByName('mymodulename');
                        $total          = floatval(number_format($cart->getOrderTotal(true, 3), 2, '.', ''));
                        $payment_module->validateOrder($cart->id, _PS_OS_PAYMENT_, 0, 'My text for payment method', null, null, 1, false, $customer->secure_key);


I'm using this code to validate this order with zero price. I mean if my conditions provided, validate this order with 0 price. With this code, order is validated, i mean i can see the order both on database and backend, but order status become 8 which is "Payment error" . I want to make it 2 which is Payment Accepted. Is this become 8 because I wrote 0 for price? Or what should I to make it "payment accepted?". I wrote same function inside of the validation class of my module, but on there, I could use "$this->module", like : 

$this->module->validateOrder($cart->id,  _PS_OS_PAYMENT_, $total, $this->module->displayName, null, null, 1, false, $customer->secure_key);

And order become 'Payment Accepted'.

 

What is the correct way to use validateOrder function, how can I set my order status (id = 2) or Payment Accepted?

Link to comment
Share on other sites

Where do you get _PS_OS_PAYMENT value from?

 

the 2nd argument after $cart->id need to be the ID number of the order status so you either use 2 or Configuration::get('PS_OS_PAYMENT')

also I recommend backing all int values with (int)

 

try like this.

 

$this->module->validateOrder((int)$cart->id, Configuration::get('PS_OS_PAYMENT'), $total, $this->module->displayName, null, null, 1, false, $customer->secure_key);

 

assuming you get cart & customer from context and your currency is 1.

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