Closed jamie-b5 closed 7 months ago
Can you try something like this instead?
use DuncanMcClean\SimpleCommerce\Facades\Order;
use DuncanMcClean\SimpleCommerce\Orders\OrderStatus;
$order = Order::find($entry->id());
return $order?->statusLog()->where('status', OrderStatus::Dispatched)->map->date()->last();
How do I combine that with computed fields?
Apologies I edited the original entry as I had put in the wrong error message
we then get the new error Call to undefined method Statamic\Entries\Entry::statusLog()
Bear with I think I can see how
Brilliant - solved!
How do I combine that with computed fields?
Oh sorry, should have included that. You can just put that code inside the computed closure. I copied it from Simple Commerce's service provider: https://github.com/duncanmcclean/simple-commerce/blob/6.x/src/ServiceProvider.php#L470-480
Description
We have upgraded to 6.1.0 but we are now unable to get the dispatched date from the status_log array.
We can display the array in the cp index field list (not great as it shows as an array).
Prior to update we used computed fields to pull out the item from the array
This now throws an error Object of class DuncanMcClean\SimpleCommerce\Orders\StatusLogEvent could not be converted to string
On the migration guide https://simple-commerce.duncanmcclean.com/upgrade-guides/v5-x-to-v6-0#content-medium-changes-to-the-statuslog-method-on-orders
It explains how to use the new method for obtaining this information.
However when I replace my old code with the new method as per below
we then get the new error Call to undefined method Statamic\Entries\Entry::statusLog()
Steps to reproduce
Environment
Environment
Application Name: Sound Organisation
Laravel Version: 10.22.0
PHP Version: 8.1.10
Composer Version: 2.4.1
Environment: local
Debug Mode: ENABLED
URL: sound_org.test
Maintenance Mode: OFF
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Drivers
Broadcasting: log
Cache: statamic
Database: mysql
Logs: stack / single
Mail: smtp
Queue: sync
Session: file
Simple Commerce
Currencies: GBP
Gateways: Stripe
Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EntryCustomerRepository
Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository
Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository
Shipping Methods: Free Overnight Shipping, Click and Collect
Tax Engine: DuncanMcClean\SimpleCommerce\Tax\Standard\TaxEngine
Statamic
Addons: 3
Antlers: runtime
Sites: 1
Stache Watcher: Disabled
Static Caching: Disabled
Version: 4.55.0 PRO
Statamic Addons
duncanmcclean/simple-commerce: 6.1.0
jezzdk/statamic-google-maps: 1.2.2
rias/statamic-data-import: 1.3.0