Closed steffenschmidt closed 2 years ago
As you've noticed, Simple Commerce won't calculate shipping costs until you actually have a shipping method selected.
I think if we were to introduce this, we'd need to make it an opt-in feature or add it into a breaking release as it may not be the behaviour that everyone would expect.
To get around this in the meantime, you could potentially listen for the OrderSaved
event emitted by Simple Commerce and if the order doesn't have a shipping_method
set, you can set it to the default one. Here's an example of what that listener may look like:
public function handle(OrderSaved $event)
{
if (! $event->order->has('shipping_method') {
$event->order->set('shipping_method', YourDefaultShippingMethod::class);
}
}
As you've noticed, Simple Commerce won't calculate shipping costs until you actually have a shipping method selected.
I think if we were to introduce this, we'd need to make it an opt-in feature or add it into a breaking release as it may not be the behaviour that everyone would expect.
Ok understood and it would be ok for me if you won‘t do it. Otherwise instead of a breaking release it could be configurable: Only if a default value is set than it calculates the grant total with the default shipping costs.
To get around this in the meantime, you could potentially listen for the OrderSaved event emitted by Simple Commerce and if the order doesn't have a shipping_method set, you can set it to the default one. Here's an example of what that listener may look like:
Thanks and I will try this for my current solution.
Released as part of v2.4.0-beta.3.
I've added the ability to configure a 'default shipping method' to the next version of Simple Commerce, v2.4. It's included as part of the latest beta release. Learn more about upgrading to the v2.4 beta.
My hope is for v2.4 to be out at the end of the month/start of next month.
Released as part of v2.4.0.
What's the issue you're running into?
Hi there,
I have three different shipping methods with different shipping costs. As they are selected in the third checkout step I would like to display a default value for shipping costs in the cart view. But the values are empty before selecting the shipping method in step three.
Any idea how to set a default shipping costs (e.g. the lowest one, or name it explicit) to show this in the shopping cart?
Cheers
Steffen
Steps to reproduce
Environment