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

Increase product excerpt default length in Single Product template and block #47651

Merged
merged 7 commits into from
May 31, 2024

Conversation

kmanijak
Copy link
Contributor

@kmanijak kmanijak commented May 21, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

In #44260 we discuss Product Summary Block: character limit and rendering behavior of different scenarios. We highlight multiple issues, among others that product summary is truncated.

There's multiple requirements to be addressed (it will be taken in multiple steps):

  • support WYSWIG styling from product editor
  • support option to NOT truncate the summary at all
  • more.

The above requires multiple actions and more research that I'm working on. However, in the meantime the least we can do is increase the word limit in Product Summary (core/post-excerpt variation) to the maximum by default. I wanted to set the limit higher (I even used "Infinity" 😅 ), but unfortunately, there's a max set in edit in Gutenberg here. So even if I put higher value (e.g. 10000), it's shows like this, which I think is very misleading especially that you cannot achieve the 10000 any other way except for inserting a block:

image

Hence, setting it to 100.

This PR covers three places where Product Summary is used:

  • Single Product block
  • default blockified Single Product template
  • the transformation of a classic Single Product template into blockified Single Product template

The PR doesn't cover Product Summary in Products (Beta) and Product Collection blocks. I kept the default value of 55 there.

How to test the changes in this Pull Request:

Using the WooCommerce Testing Instructions Guide, include your detailed testing instructions:

Prerequisites:
0. Edit some product and add some description longer than 100 words:

Example content Lorem ipsum dolor sit amet, consectetur adipiscing elit. Phasellus sed nibh blandit, sodales enim aliquet, ultricies ligula. Praesent enim lectus, gravida a sapien eget, venenatis tempor ligula. Etiam cursus, nisl id molestie rutrum, ex velit volutpat arcu, at blandit quam lectus ut urna. Sed at venenatis turpis, convallis laoreet ante. Nulla lobortis odio non est eleifend, eu vulputate arcu pharetra. Pellentesque porta ante non mauris rutrum consectetur. Quisque nulla neque, vestibulum sed consectetur eget, pellentesque quis felis. Nullam maximus felis neque, a efficitur velit venenatis vitae. Praesent elit sem, bibendum id malesuada sit amet, tristique non turpis. Vivamus varius venenatis sem auctor semper. Cras imperdiet risus diam, sit amet tincidunt dui dictum posuere.

Duis ut tellus fermentum arcu efficitur posuere. Sed tincidunt, nulla a porttitor sagittis, felis felis condimentum felis, ut bibendum augue lacus eu orci. Vestibulum consequat condimentum viverra. Duis pharetra turpis vel varius malesuada. Quisque id velit id.

Scenario 1 - transform classic template into blockified

  1. Go to Editor -> Single Product template
  2. Remove the content and insert "WooCommerce Single Product Block"
  3. Hover over it and click "Transform into blocks"
  4. Enter "Code Editor" mode
  5. Look for "post-except"
  6. Make sure it has "excerptLength":100
image
  1. Save and visit product with longer description on the frontend
  2. Make sure it's truncated on 100 words not 55 (no need to count words, asses the "volume" of the text based on below screenshots 🙌 )
Before After
image image

Scenario 2 - default template

  1. Clear customizations on Single Product template
  2. Repeat steps 4 - 8 from Scenario 1

Scenario 3 - Single Product block

  1. Add new post
  2. Add Single Product block
  3. Choose product with longer description
  4. Focus on "Product Summary" block
  5. Make sure Inspector Controls show max words 100 by default
image
  1. Save and go to frontend
  2. Make sure it's truncated on 100 words, not 55 (no need to count words, asses the "volume" of the text based on above screenshots 🙌 )

Changelog entry

  • Automatically create a changelog entry from the details below.

Significance

  • Patch
  • Minor
  • Major

Type

  • Fix - Fixes an existing bug
  • Add - Adds functionality
  • Update - Update existing functionality
  • Dev - Development related task
  • Tweak - A minor adjustment to the codebase
  • Performance - Address performance issues
  • Enhancement - Improvement to existing functionality

Message

Comment

@kmanijak kmanijak added the block: product summary Issue related to the Product Summary block label May 21, 2024
@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label May 21, 2024
@kmanijak kmanijak added team: Kirigami & Origami WC Store Editing (FSE) type: enhancement The issue is a request for an enhancement. and removed plugin: woocommerce Issues related to the WooCommerce Core plugin. labels May 21, 2024
Copy link
Contributor

github-actions bot commented May 21, 2024

Test using WordPress Playground

The changes in this pull request can be previewed and tested using a WordPress Playground instance.
WordPress Playground is an experimental project that creates a full WordPress instance entirely within the browser.

Test this pull request with WordPress Playground.

Note that this URL is valid for 30 days from when this comment was last updated. You can update it by closing/reopening the PR or pushing a new commit.

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label May 21, 2024
@kmanijak kmanijak marked this pull request as ready for review May 21, 2024 13:12
@woocommercebot woocommercebot requested review from a team and ObliviousHarmony and removed request for a team May 21, 2024 13:13
Copy link
Contributor

Hi @ObliviousHarmony,

Apart from reviewing the code changes, please make sure to review the testing instructions as well.

You can follow this guide to find out what good testing instructions should look like:
https://github.com/woocommerce/woocommerce/wiki/Writing-high-quality-testing-instructions

Copy link
Contributor

@ObliviousHarmony ObliviousHarmony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Howdy @kmanijak,

I've gone through the testing instructions and have encountered some issues!

Scenario 1 - transform classic template into blockified

  • No Short Description: Unfortunately, this truncates at 55 words still.
  • Short Description: When the short description is present it truncates at 100 as expected.

Scenario 2 - default template

  • The behavior of Scenario 2 is the same as Scenario 1.

Scenario 3 - Single Product block

  • While the excerpt block shows 100 as the value the behavior is still the same as the other two scenarios.

@kmanijak kmanijak changed the title Add/increase product excerpt default length Increase product excerpt default length in Single Product template and block May 22, 2024
@kmanijak
Copy link
Contributor Author

No Short Description: Unfortunately, this truncates at 55 words still.

Great catch @ObliviousHarmony!

I did some digging and the truncation happens in WordPress itself:

If this function is used outside The Loop and the post doesn’t have a custom excerpt, this function will use wp_trim_excerpt() to generate an excerpt.

Returns a maximum of 55 words with an ellipsis appended if necessary.
The 55-word limit can be modified by plugins/themes using the ‘excerpt_length’ filter.

The same happens on trunk if the user manually sets the excerpt length to a value higher than 55, excerpt length will be "ignored" if there's no short description and content is truncated to 55 internally. I recommend progressing with the PR to improve the behavior at least in some cases.

I'll contribute upstream to add excerpt_length filter in post-excerpt.

As I wrote in the PR description, this is just short-term improvement and I'm focusing on providing an alternative solution to core/post-excerpt variation.

@kmanijak
Copy link
Contributor Author

Made a contribution to Gutenberg fixing the problem: WordPress/gutenberg#61888

Copy link
Contributor

@ObliviousHarmony ObliviousHarmony left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for looking into that and submitting an upstream fix @kmanijak 😄

Since we can't fix that edge case, let's go ahead with this!

@kmanijak kmanijak merged commit fe30778 into trunk May 31, 2024
46 checks passed
@kmanijak kmanijak deleted the add/increase-product-excerpt-default-length branch May 31, 2024 06:19
@github-actions github-actions bot added this to the 9.1.0 milestone May 31, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label May 31, 2024
@rodelgc rodelgc removed the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jun 5, 2024
@rodelgc rodelgc added needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. status: analysis complete Indicates if a PR has been analysed by Solaris labels Jun 5, 2024
thealexandrelara pushed a commit that referenced this pull request Jul 18, 2024
…d block (#47651)

* Increase the length of Product Summary block (core/post-excerpt variation)

* Add changelog

* Bring back the Product Summary variation to original length

* Increase the Product Summary length to max 100 words in Single Product template and block

* Increase the Product Summary length to max 100 words in Single Product block

* Update tests

* Change the attribute type froms tring to niumber as expected
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block: product summary Issue related to the Product Summary block needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. plugin: woocommerce Issues related to the WooCommerce Core plugin. status: analysis complete Indicates if a PR has been analysed by Solaris team: Kirigami & Origami WC Store Editing (FSE) type: enhancement The issue is a request for an enhancement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants