Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Define default shipping costs before selecting #555

Closed
steffenschmidt opened this issue Jan 28, 2022 · 5 comments
Closed

Define default shipping costs before selecting #555

steffenschmidt opened this issue Jan 28, 2022 · 5 comments

Comments

@steffenschmidt
Copy link
Contributor

steffenschmidt commented Jan 28, 2022

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

  • Three shipping methods: Normal (4 €), Fast (8 €), Express (12 €)
  • Put a product in your basket
  • Shown shipping costs in basket are empty
  • Proceed to checkout
  • Shipping costs are filled after selecting

Environment

Statamic 3.2.32 Pro
Laravel 8.81.0
PHP 8.1.0
aryehraber/statamic-logbook 2.0.2
doublethreedigital/simple-commerce 2.3.64
jackabox/statamic-plausible-analytics 1.1.0
@duncanmcclean
Copy link
Owner

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);
    }
}

@steffenschmidt
Copy link
Contributor Author

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.

@github-actions
Copy link

github-actions bot commented Feb 5, 2022

Released as part of v2.4.0-beta.3.

@duncanmcclean
Copy link
Owner

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.

@github-actions
Copy link

Released as part of v2.4.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants