Use a theme function for rendering "there is no shipping rate"

Created on 2 August 2024, 4 months ago
Updated 20 September 2024, 2 months ago

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

โœจ Feature request
Status

RTBC

Version

2.0

Component

Code

Created by

๐Ÿ‡ซ๐Ÿ‡ทFrance Renrhaf ๐Ÿ“ Strasbourg ๐Ÿฆ๐Ÿฆœ

Live updates comments and jobs are added and updated live.
  • theming

    Used in Documentation issues related to theming

Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @Renrhaf
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance Renrhaf ๐Ÿ“ Strasbourg ๐Ÿฆ๐Ÿฆœ
  • Pipeline finished with Success
    4 months ago
    Total: 319s
    #241828
  • Issue was unassigned.
  • Status changed to Needs review 4 months ago
  • ๐Ÿ‡ซ๐Ÿ‡ทFrance Renrhaf ๐Ÿ“ Strasbourg ๐Ÿฆ๐Ÿฆœ
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    Great! We should combine this with ๐Ÿ› Improve "no shipping rates" message. Needs review 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 ๐Ÿ› Improve "no shipping rates" message. Needs review .

    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!

  • Status changed to Needs work 2 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    From 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?

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    I'd rather fix the issue here.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    grevil โ†’ changed the visibility of the branch 8.x-2.x to hidden.

  • Pipeline finished with Canceled
    2 months ago
    Total: 73s
    #287315
  • Pipeline finished with Success
    2 months ago
    Total: 300s
    #287316
  • Status changed to Needs review 2 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    Done. Please review!

  • Pipeline finished with Success
    2 months ago
    Total: 383s
    #287323
  • Pipeline finished with Success
    2 months ago
    Total: 269s
    #287994
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    Thanks, @Anybody! I used a bad example to implement the attributes. LGTM now!

    <div class="commerce-shipping-no-shipping-rates" data-drupal-selector="edit-shipping-information-shipments-0-shipping-method-0">
      Es sind keine Versandkosten fรผr diese Adresse verfรผgbar.
    </div>
    
  • Status changed to RTBC 2 months ago
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    @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?

    Another thing I thought about is, if it might be helpful for any case to pass the $shipment variable to the twig file?

    Let's wait for maintainer feedback on this in general and these points.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    Before:

    After:

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    Added the shipment entity to the theme, might make sense to get the title of the shipment or something along those lines.

  • Pipeline finished with Success
    2 months ago
    Total: 503s
    #290128
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    Nice and thank you for the before / after screenshots! RTBC

  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    hm... I don't really see any difference between the before / after? Are we supposed to see any?

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    hm... I don't really see any difference between the before / after? Are we supposed to see any?

    No not really! But it's easily overridable now. :)

  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    Not really RTBC, there are phpcs failures, tests are failing too with D11, but I don't think the failures are related.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Anybody Porta Westfalica

    As of #19, thanks for the feedback. PHPCS also seem unrelated in large parts, but we'll check that...

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    Current 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.

  • Merge request !50Test pipeline โ†’ (Open) created by Grevil
  • Pipeline finished with Success
    2 months ago
    Total: 487s
    #290219
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    Yep, simply adding another hashtag in the .gitlab-ci.yml will 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.

  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick

    Shouldn't we have a class name consistent with the theme function? (i.e. commerce-shipping-rates-empty?)

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    Sure! Adjusted accordingly.

  • Pipeline finished with Success
    2 months ago
    #290266
  • ๐Ÿ‡ฎ๐Ÿ‡ฑIsrael jsacksick
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany Grevil

    Thanks, @jsacksick! ๐ŸŽ‰

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024