Problem/Motivation
In the shipping information pane, we display the available rates.
When no rates are available for the chosen address, there is a text displayed.
This text "There are no shipping rates available for this address." is not overridable easily (without overriding the whole plugin).
Proposed resolution
Use a theme function for rendering this text, so themes can easily override it and style it.
Remaining tasks
Define a theme function, a template, replace the markup with the proper render array.
User interface changes
None
API changes
None
Data model changes
None
| Comment | File | Size | Author |
|---|---|---|---|
| #14 | 2024-09-23 09_31_43-Zur Kasse _ Bilderrahmen-passt.de_.png | 16.52 KB | grevil |
| #14 | 2024-09-23 09_27_58-Zur Kasse _ Bilderrahmen-passt.de_.png | 16.83 KB | grevil |
Issue fork commerce_shipping-3465474
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
renrhafComment #4
renrhafComment #5
anybodyGreat! We should combine this with #3473333: Improve "no shipping rates" message. in one of both issues, I think.
I think instead of the
<p>we should use a<div>with a dedicated and a general (warning / error) class.Furthermore, we should decide for one of both issues to also discuss the other points mentioned over there in #3473333: Improve "no shipping rates" message..
This is the older issue, but due to the discussion and other points over there, I'd suggest to move the solution from here over and close this issue!
Please don't forget crediting @renrhaf!
Comment #6
grevil commentedFrom the other issue:
Thanks @Grevil, I agree that this is currently a bit confusing. Would be even better to also adjust the Drupal form message (empty required field) if no shipping method matches.
Maybe we should even allow defining a configurable fallback message for that case as a setting, so that shop owners can explain the potential reasons in this case instead of a hard-coded message?
Let's wait for Centarro feedback on that.
Regarding the class: I think it would make sense to add a context class like you did, and also add a Drupal error or warning message class to show the message appropriately by default.
I'm unsure if such a class exists, or if that means we'd have to use something like the message's markup?
@jsacksick what are your thoughts here?
Comment #7
grevil commentedI'd rather fix the issue here.
Comment #10
grevil commentedDone. Please review!
Comment #11
grevil commentedThanks, @Anybody! I used a bad example to implement the attributes. LGTM now!

Comment #12
anybody@grevil thanks! Could you provide a before / after screenshot perhaps?
Code-wise I think this is helpful and a lot more flexible than before! RTBC from my side. For further discussion:
It would be great to add a warning class, but I think also Olivero has no
warning-styles outside of messages and I don't think it would be correct to add message markup here?It would be a wrapper with
.messages.messages--error / --warning / --status / --infoAnother thing I thought about is, if it might be helpful for any case to pass the
$shipmentvariable to the twig file?Let's wait for maintainer feedback on this in general and these points.
Comment #13
grevil commentedComment #14
grevil commentedBefore:

After:

Comment #15
grevil commentedAdded the shipment entity to the theme, might make sense to get the title of the shipment or something along those lines.
Comment #16
anybodyNice and thank you for the before / after screenshots! RTBC
Comment #17
jsacksick commentedhm... I don't really see any difference between the before / after? Are we supposed to see any?
Comment #18
grevil commentedNo not really! But it's easily overridable now. :)
Comment #19
jsacksick commentedNot really RTBC, there are phpcs failures, tests are failing too with D11, but I don't think the failures are related.
Comment #20
anybodyAs of #19, thanks for the feedback. PHPCS also seem unrelated in large parts, but we'll check that...
Comment #21
grevil commentedCurrent changes don't contain anything that would violate the Drupal coding standards, the phpunit test seems very unrelated as well. I bet, if we rerun the pipeline on the current dev build, we get the same errors.
Comment #23
grevil commentedYep, simply adding another hashtag in the
.gitlab-ci.ymlwill result in the same pipeline failures (see MR !50). The pipeline in 8.x-2.x will have the same errors if rebuilt.Setting back to RTBC, as the failures are unrelated.
Comment #24
jsacksick commentedShouldn't we have a class name consistent with the theme function? (i.e. commerce-shipping-rates-empty?)
Comment #25
grevil commentedSure! Adjusted accordingly.
Comment #27
jsacksick commentedComment #28
grevil commentedThanks, @jsacksick! 🎉