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

Shipping rule conditions if total is 0 #2178

Closed
valentin- opened this issue Jan 19, 2023 · 14 comments
Closed

Shipping rule conditions if total is 0 #2178

valentin- opened this issue Jan 19, 2023 · 14 comments
Assignees
Labels
Milestone

Comments

@valentin-
Copy link
Contributor

Q A
Bug report? yes (amount condition from = 0)
Feature request? yes (amount condition based on total price)
BC Break report? no
RFC? no

Hi, I'd like to add a shipping condition based on the total price.

  • If the price is 0 there should be a shipping option with free shipping
  • The other shipping rules should get applied, if the total price is > 0

Currently the amount condition is based on the subtotal, not the total price - therefore it won't apply if the total price is 0 at the end.

image

Also I'd like to set from = 0 / to = 1 for the free shipping option (and from = 1 / to = 0/null for the paid options), but setting 0 as from value is not possible currently.

image

Thanks in advance!
Valentin

@dpfaffenbauer
Copy link
Member

@valentin- what is the total of your order? I guess it is has a shipping applied to it right?

@valentin-
Copy link
Contributor Author

@dpfaffenbauer no there is no difference between selecting a shipping with/without a price, regarding the available shipping options based on the price.

It will only display if the max price is higher than the subtotal.

image
image

@valentin-
Copy link
Contributor Author

@dpfaffenbauer could we check on this again? Thank you

@dpfaffenbauer
Copy link
Member

@valentin- sure, can you elaborate the problem more detailed pls? I cannot really seem to understand the issue.

@valentin-
Copy link
Contributor Author

So I'd like to add shipping rule (free) with 0 € if the total cart price is 0.

  • I've added a product to the cart -> 22,90
  • Apply a cart rule -100%
  • Subtotal -> 22,90
  • Total -> 0

Therefore I'd like to add a shipping rule which shows up when the total price <= 1.

But the max price is based on the subtotal, not on the total. Therefore the rule for max <= 1 can't be used.

The "free" shipping rule only shows up, if max price is > subtotal.

image
image

I'd like to show the rule if the total price <= 1

image

Is it clearer now? Thanks for your support.

@dpfaffenbauer
Copy link
Member

@valentin- for me it seems to work, this is my setup:
Screenshot 2023-03-15 at 14 57 40
Screenshot 2023-03-15 at 14 57 44
Screenshot 2023-03-15 at 14 57 47
Screenshot 2023-03-15 at 14 57 49

@valentin-
Copy link
Contributor Author

Hi @dpfaffenbauer,

indeed it works with min = 0 and max = 0. But to switch the options I'd like to set following rules:

Free shipping: Min 0, Max 1 (not visible anymore) -> only works with 0/0
Other shipping (paid): Min 1, Max 0 (or 999999) -> only get's hidden if min > subtotal, not the total

Also I've experienced an error when switching from shipping method with shipping costs to a free shipping method. Should there be a summary redirect added if the cart is free (without payment)?

image

Thanks!

@dpfaffenbauer
Copy link
Member

Ok, I think the problem is that the shipping is part of the "total" cart value. Does it help if you add change the following line:

src/CoreShop/Component/Shipping/Rule/Condition/AmountConditionChecker.php:34 to

$totalAmount = min(0, $shippable->getSubtotal($gross) - $shippable->getAdjustmentsTotal(AdjustmentInterface::SHIPPING));

@valentin-
Copy link
Contributor Author

Yes this will output the shipping options as expected.

@dpfaffenbauer
Copy link
Member

@valentin- then we have a fix :), I'll create a PR

@dpfaffenbauer
Copy link
Member

@valentin- this breaks the tests for some reason, so it might take a bit longer for that to be merged

@dpfaffenbauer
Copy link
Member

@valentin- I made some changes to the PR. Basically I've added a checkbox in the amount configuration to use the total value, could you test that on your side? #2238

@dpfaffenbauer
Copy link
Member

ping @valentin-

@valentin-
Copy link
Contributor Author

@dpfaffenbauer I was on vaccaction last week.
I checked out the latest commit and tested it locally, works as expected.

Thank you!

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

No branches or pull requests

2 participants