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

Product Collection: Make sure all variations are taken into account when choosing collection #43273

Merged
merged 2 commits into from Jan 8, 2024

Conversation

kmanijak
Copy link
Contributor

@kmanijak kmanijak commented Jan 4, 2024

Submission Review Guidelines:

Changes proposed in this Pull Request:

Product Collection offers a set of Core collections. If 3PD registers their own variation/collection, it appears as a choice in the Product Collection placeholder but when clicked, there was an error.

This PR enables to apply any 3PD variation/collection.

Closes #43214

How to test the changes in this Pull Request:

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

  1. Go to Editor
  2. Open developer tools in browsers and paste the following code in the console
const attributes = {
	tagName: 'div',
	displayLayout: {
		type: 'flex',
		columns: 3,
		shrinkColumns: true,
	},
	query: {
		perPage: 9,
		pages: 0,
		offset: 0,
		postType: 'product',
		order: 'asc',
		orderBy: 'title',
		search: '',
		exclude: [],
		taxQuery: {},
		isProductCollectionBlock: true,
		featured: false,
		woocommerceOnSale: false,
		woocommerceStockStatus: [],
		woocommerceAttributes: [],
		woocommerceHandPickedProducts: [],
		timeFrame: undefined,
		priceRange: undefined,
		inherit: false,
	},
	collection: 'woocommerce/product-collection/custom-collection',
};

const innerBlocks = [
	[
		'woocommerce/product-template',
		{},
		[
			[ 'woocommerce/product-image' ],
			[
				'core/post-title',
				{
					textAlign: 'center',
					level: 3,
					fontSize: 'medium',
					style: {
						spacing: {
							margin: {
								bottom: '0.75rem',
								top: '0',
							},
						},
					},
					isLink: true,
					__woocommerceNamespace:
						'woocommerce/product-collection/product-title',
				},
			],
			[
				'woocommerce/product-price',
				{
					textAlign: 'center',
					fontSize: 'small',
				},
			],
			[
				'woocommerce/product-button',
				{
					textAlign: 'center',
					fontSize: 'small',
				},
			],
		],
	],
];

wp.blocks.registerBlockVariation( 'woocommerce/product-collection', {
	name: 'woocommerce/product-collection/custom-collection',
	title: '3PD collection',
	description:
		'3PD collection description. It appears in placeholder and can be chosen',
        isActive: (blockAttrs, variationAttributes) => {
			return blockAttrs.collection === variationAttributes.collection
	},
	attributes,
	innerBlocks,
} );
  1. Add Product Collection block
  2. 3PD collection should appear in the Product Collection placeholder
  3. Click 3PD collection
  4. Product grid is rendered, there's no error and block appears as 3PD collection
image

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

@github-actions github-actions bot added the plugin: woocommerce Issues related to the WooCommerce Core plugin. label Jan 4, 2024
Copy link
Contributor

github-actions bot commented Jan 4, 2024

Test Results Summary

Commit SHA: 491c438

Test 🧪Passed ✅Failed 🚨Broken 🚧Skipped ⏭️Unknown ❔Total 📊Duration ⏱️
API Tests25900202610m 37s
E2E Tests258003026115m 1s

To view the full API test report, click here.
To view the full E2E test report, click here.
To view all test reports, visit the WooCommerce Test Reports Dashboard.

@kmanijak kmanijak changed the title Add/43214 allow adding external collections Product Collection: Make sure all variations are taken into account when choosing collection Jan 4, 2024
@kmanijak kmanijak marked this pull request as ready for review January 4, 2024 14:31
@woocommercebot woocommercebot requested review from a team and Aljullu and removed request for a team January 4, 2024 14:31
Copy link
Contributor

github-actions bot commented Jan 4, 2024

Hi @xristos3490, @Aljullu,

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
Member

@xristos3490 xristos3490 left a comment

Choose a reason for hiding this comment

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

Nice work, @kmanijak! Tested with a custom collection and it works as expected! 👌

Copy link
Contributor

@Aljullu Aljullu left a comment

Choose a reason for hiding this comment

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

This is testing well and code looks good to me. 🚢

@kmanijak kmanijak merged commit 8d4f1ce into trunk Jan 8, 2024
44 checks passed
@kmanijak kmanijak deleted the add/43214-allow-adding-external-collections branch January 8, 2024 09:55
@github-actions github-actions bot added this to the 8.6.0 milestone Jan 8, 2024
@github-actions github-actions bot added the needs: analysis Indicates if the PR requires a PR testing scrub session. label Jan 8, 2024
@rodelgc rodelgc added status: analysis complete Indicates if a PR has been analysed by Solaris needs: external testing Indicates if the PR requires further testing conducted by testers external to the development team. and removed needs: analysis Indicates if the PR requires a PR testing scrub session. labels Jan 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
block: product collection Issues related to the Product Collection block category: extensibility 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
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow 3PD collection types to be selected on the collection type chooser modal
4 participants