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

Variant Options Abstraction #1044

Closed
korgon opened this issue May 20, 2024 · 0 comments · Fixed by #1047
Closed

Variant Options Abstraction #1044

korgon opened this issue May 20, 2024 · 0 comments · Fixed by #1047
Assignees
Labels
type: feature New functionality

Comments

@korgon
Copy link
Contributor

korgon commented May 20, 2024

// internally handle inside snap-preact via document click event listener (ala ss-tracker)
// inspect each click event looking for ss-variant-option it should contain "option:value"
// this event handler will fire the global event 'controller/selectVariantOptions' with the option and value

Pseudo-JS:

document.querySelectorAll('[ss-variant-option]').onClick(e => {
	const target = e.target;
	const [option, value] = target.getAttribute('data-ss-option').split(':');

	const options = {};
	options[option] = value;

	searchspring.fire('controller/selectVariantOptions', {
		// controllerIds: [/^recommend_bundle/], // if no controller ids are provided...
		options,
	});
});

add realtime setting to variants controller settings:

{
	id,
	settings: {
		variants: {
			field: 'ss_variants',
			realtime: {
				enabled: true,
				filter: 'first', // ---  ['first', 'unaltered'],
				// filterFunction - maybe add later as needed?  filter(({ products, controller }) => products)
			},
		},
	}
}

recommendation profiles can be set individually via script context (or globally via instantiator config - must merge together)

<script searchspring-recommend="tagName">
	options = {
		realtime: true,
		variants: {
			realtime: {
				enabled: true,
			},
		},
	}
</script>
@korgon korgon added the type: feature New functionality label May 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature New functionality
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants