Can't display the Date an order was placed #947
-
There seems to be no way to display the date in the Orders overview OR the order detail. In context of a webshop, this feels important. I've done a search for similar discussions/issues: To me, it feels like a missing feature; and would be of great value to have it in SC. |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 3 replies
-
Hey 👋 Yes, I know. It was accidentally removed after some changes to the way order/payment statuses work in v5 but I'm planning to add it back in v6 (which I'm planning to release Q1 next year), see #896. In the meantime, you can add it using a Computed Field.
// app/Providers/AppServiceProvider.php
public function boot()
{
// ...
\Statamic\Facades\Collection::computed('orders', 'order_date', function ($entry, $value) {
return \Illuminate\Support\Arr::get($entry->get('status_log'), 'placed');
});
}
|
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
That were the right steps in the right direction, thanks! Btw, I noticed that I also had to switch the model referenced in runway.php |
Beta Was this translation helpful? Give feedback.
-
I've been making some changes to how the "status log" feature works and in the process, I've added an "Order Date" field to orders so you don't need to do it yourself. After updating to v5.7.0, you can follow my previous set of instructions in reverse. (get rid of the custom Eloquent model, switch back to the "base" Simple Commerce one). The only thing you'll want to keep is the |
Beta Was this translation helpful? Give feedback.
Oh, sorry, didn't realise you were storing orders in a database, in which case editing the
resources/order.yaml
blueprint is correct. You can delete the "Orders" collection and its blueprint since you're not using entries.However, instead of the computed code in the
AppServiceProvider
, you'll need to override the Order Eloquent model and create a model accessor to return the order date.App\Models
calledOrder.php
, with the following contents: