1

Currently trying to use the new Donations feature of Commerce 2 - https://docs.craftcms.com/commerce/v2/donations.html

The order goes through fine and I can see the donation purchasable in the order.

What I can't do though is get it to assign the status of Donation to the donation/order. It currently comes through as a New status.

This is extremely handy to break apart Orders from Donations and vice versa.

Is there a way to set the donation status as default to all donations, or somehow assigning the status to the donation via the form when the payment is processed?

2

Donations are like anything else, and can be bought along side regular products so they are a part of normal orders.

You can use the event below to inspect the order and choose youre own default status if you want.

use craft\commerce\events\DefaultOrderStatusEvent;
use craft\commerce\services\OrderStatuses;
use yii\base\Event;

Event::on(OrderStatuses::class, OrderStatuses::EVENT_DEFAULT_ORDER_STATUS, function(DefaultOrderStatusEvent $e) {
 // Do something - perhaps figure out a better default order statues than the one set in CP
 // $e->order
 // $e->orderStatus (the order status to set as the default for this order)
});
|improve this answer|||||
  • That seems like a good option for me, as currently we're only allowing 1 item in the cart either a Product or Donation. So i'll give this a go. – Jason Mayo Mar 13 '19 at 13:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.