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

Single product templates that have been edited by the merchant can't be selected in the edit product screen #42630

Closed
Aljullu opened this issue May 30, 2022 · 3 comments
Labels
focus: FSE Issues related to Full Site Editing team: Kirigami & Origami type: bug The issue is a confirmed bug.

Comments

@Aljullu
Copy link
Contributor

Aljullu commented May 30, 2022

This issue might require changes in WC core or Gutenberg repos, but I'm creating this in WC Blocks repo for ease of tracking it.

To reproduce

  1. In Twenty Twenty Two, create a new template, ie: /themes/twentytwentytwo/templates/another-single-product.html
<!-- wp:template-part {"slug":"header"} /-->
<!-- wp:group {"layout":{"inherit":true}} -->
<div class="wp-block-group"><!-- wp:woocommerce/legacy-template {"template":"single-product"} /--></div>
<!-- /wp:group -->
<!-- wp:template-part {"slug":"footer"} /-->
  1. Add it to customTemplates in theme.json:
{
	"version": 2,
	"customTemplates": [
		...
		{
			"name": "another-single-product",
			"title": "Another Single Product Template",
			"postTypes": [
				"product"
			]
		}
	],
	...
}
  1. Go to WooCommerce > Products and edit one of the products.
  2. Notice you can select between the default template and Another Single Product Template.

Screenshot showing the select to choose the template.

  1. Go to Appearance > Editor > Templates > Another Single Product Template, make an edit and save the edited template.
  2. Now, go back to editing a product.
  3. Notice Another Single Product Template is no longer listed as an available template.

Expected behavior

If the merchant makes an edit to a template that has postTypes: [ 'product' ], it should still be available when editing or creating products.

More info

I think the issue comes from the fact that WC uses get_block_template(), which internally calls _build_block_template_result_from_post(). And the latter, doesn't add a post_types attribute to templates returned.

@Aljullu Aljullu added type: bug The issue is a confirmed bug. focus: FSE Issues related to Full Site Editing labels May 30, 2022
@Aljullu
Copy link
Contributor Author

Aljullu commented May 31, 2022

I created an issue in trac, I think that should ideally be fixed upstream:

https://core.trac.wordpress.org/ticket/55881#ticket

@github-actions
Copy link
Contributor

This issue has been marked as stale because it has not seen any activity within the past 60 days. Our team uses this tool to help surface issues for review. If you are the author of the issue there's no need to comment as it will be looked at.

Internal: After 10 days with no activity this issue will be automatically be closed.

@github-actions github-actions bot added the status: stale Issues that have no had any activity for some time. label Jul 31, 2022
@Aljullu Aljullu removed the status: stale Issues that have no had any activity for some time. label Aug 1, 2022
@ObliviousHarmony ObliviousHarmony transferred this issue from woocommerce/woocommerce-blocks Dec 11, 2023
@tjcafferkey
Copy link
Contributor

Can confirm this has been fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
focus: FSE Issues related to Full Site Editing team: Kirigami & Origami type: bug The issue is a confirmed bug.
Projects
None yet
Development

No branches or pull requests

3 participants