THELIA Forum

Welcome to the THELIA support and discusssion forum

Announcement

Rejoignez la communauté sur le Discord Thelia : https://discord.gg/YgwpYEE3y3

Offline


Hi all,

In the supplied module FreeOrder which is meant to allow orders of $0.00 to be processed bypassing the payment system, there is no code included to set the order status to paid after it has been purchased. I am trying to set this up, but Im not sure the correct place to do it.

It would seem that I should be able to quickly set the status of the order in the Pay() function of the FreeOrder module, as there is no way payment can fail for $0.00 value on free orders. I cant seem to correctly call the right functions from this area to complete the status change.

I could set up a callback URL with a success function to set the order status similar to the paypal module, but as there is no way this payment can fail it seems overkill to build that structure for a free order.

Has anyone else come across this issue? How has anyone solved it, or can anyone point me to the correct functions to use in the pay() function to set status of the order. Currently I am trying:

public function pay(Order $order)
{
    $event = new OrderEvent($order);
    $event->setStatus(OrderStatusQuery::getPaidStatus()->getId());
    $this->dispatch(TheliaEvents::ORDER_UPDATE_STATUS,$event);
}

But getting error:
Call to undefined function FreeOrder\dispatch()

Thanks for any help.
Sam

Offline


Try this :

    public function pay(Order $order)
    {
        $event = new OrderEvent($order);
        $event->setStatus(OrderStatusQuery::getPaidStatus()->getId());
        $this->getDispatcher()->dispatch(TheliaEvents::ORDER_UPDATE_STATUS,$event);
    }

OpenStudio Toulouse

Offline


Thankyou very much, this works perfectly. Can I add a pull request for this module or will you guys update it yourself? It seems that this module should definately mark orders as paid when complete.

Offline


I just did the PR :-)


OpenStudio Toulouse