class ShippingCalculator
{
public function handle(Order $order, Closure $next)
{
$shippingMethod = $order->get('shipping_method');
$defaultShippingMethod = config('simple-commerce.sites.'.Site::current()->handle().'.shipping.default_method');
if (! $shippingMethod && ! $defaultShippingMethod) {
return $next($order);
}
$order->shippingTotal(
Shipping::site(Site::current()->handle())
->use($defaultShippingMethod::handle())
->calculateCost($order)
);
return $next($order);
}
}
Removing the ::handle() from ->use($defaultShippingMethod::handle()) fixed the issue for me, because the value of $defaultShippingMethod declared earlier is already a handle.
Steps to reproduce
Define default_method with a handle
Go to cart
Get error 'Class "mailbox_shipping" not found where mailbox_shipping is the handle I used
Environment
Environment
Application Name: Op Adventuur
Laravel Version: 10.44.0
PHP Version: 8.2.16
Composer Version: 2.7.1
Environment: local
Debug Mode: ENABLED
URL: ndl3nw4ehg.sharedwithexpose.com
Maintenance Mode: OFF
Cache
Config: NOT CACHED
Events: NOT CACHED
Routes: NOT CACHED
Views: CACHED
Description
When upgrading from v5 to v6 the default shipping method selection stopped working. My code that defines the default shipping method is this:
And when I open up the cart, i get this error:
After some digging, I found this piece of code:
Removing the
::handle()
from->use($defaultShippingMethod::handle())
fixed the issue for me, because the value of $defaultShippingMethod declared earlier is already a handle.Steps to reproduce
'Class "mailbox_shipping" not found
where mailbox_shipping is the handle I usedEnvironment
Environment Application Name: Op Adventuur Laravel Version: 10.44.0 PHP Version: 8.2.16 Composer Version: 2.7.1 Environment: local Debug Mode: ENABLED URL: ndl3nw4ehg.sharedwithexpose.com Maintenance Mode: OFF
Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED
Drivers Broadcasting: log Cache: statamic Database: sqlite Logs: stack / single Mail: smtp Queue: sync Session: file
Simple Commerce Currencies: EUR Gateways: Mollie Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EntryCustomerRepository Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository Shipping Methods: Mailbox Shipping, parcel_shipping Tax Engine: DuncanMcClean\SimpleCommerce\Tax\Standard\TaxEngine
Statamic Addons: 4 Antlers: runtime Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 4.49.0 PRO
Statamic Addons aerni/font-awesome: 2.0.0 duncanmcclean/simple-commerce: 6.0.7 mattrothenberg/statamic-mapbox-address: 0.7.4 withcandour/aardvark-seo: 3.0.1
❯ php please support:details
Environment Application Name: Op Adventuur Laravel Version: 10.44.0 PHP Version: 8.2.16 Composer Version: 2.7.1 Environment: local Debug Mode: ENABLED URL: ndl3nw4ehg.sharedwithexpose.com Maintenance Mode: OFF
Cache Config: NOT CACHED Events: NOT CACHED Routes: NOT CACHED Views: CACHED
Drivers Broadcasting: log Cache: statamic Database: sqlite Logs: stack / single Mail: smtp Queue: sync Session: file
Simple Commerce Currencies: EUR Gateways: Mollie Repository: Customer: DuncanMcClean\SimpleCommerce\Customers\EntryCustomerRepository Repository: Order: DuncanMcClean\SimpleCommerce\Orders\EntryOrderRepository Repository: Product: DuncanMcClean\SimpleCommerce\Products\EntryProductRepository Shipping Methods: mailbox_shipping, parcel_shipping Tax Engine: DuncanMcClean\SimpleCommerce\Tax\Standard\TaxEngine
Statamic Addons: 4 Antlers: runtime Sites: 1 Stache Watcher: Enabled Static Caching: Disabled Version: 4.49.0 PRO
Statamic Addons aerni/font-awesome: 2.0.0 duncanmcclean/simple-commerce: 6.0.7 mattrothenberg/statamic-mapbox-address: 0.7.4 withcandour/aardvark-seo: 3.0.1