Show Product Subparts only for certain types of products

Help for integrating the Laravel package
Forum rules
Always add your Laravel, Aimeos and PHP version as well as your environment (Linux/Mac/Win)
Spam and unrelated posts will be removed immediately!
jafo66
Posts: 65
Joined: 06 Mar 2024, 04:42

Show Product Subparts only for certain types of products

Post by jafo66 » 22 Jul 2024, 12:53

I'm looking to show / hide certain subparts in the product page based on the type of product. Same functionality as seen with variants currently.

Is there a method to do that?

Thanks!

User avatar
aimeos
Administrator
Posts: 8244
Joined: 01 Jan 1970, 00:00

Re: Show Product Subparts only for certain types of products

Post by aimeos » 24 Jul 2024, 09:55

Display or hide tabs based on the selected product type is done here:
https://github.com/aimeos/ai-admin-jqad ... ct.js#L729
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jafo66
Posts: 65
Joined: 06 Mar 2024, 04:42

Re: Show Product Subparts only for certain types of products

Post by jafo66 » 24 Jul 2024, 12:08

Is there a good method to add an item to that list or do I need to override the entire product.js file? NOTE: to be clear, I'm trying to avoid having my own version of the file.

User avatar
aimeos
Administrator
Posts: 8244
Joined: 01 Jan 1970, 00:00

Re: Show Product Subparts only for certain types of products

Post by aimeos » 25 Jul 2024, 10:08

You only need to overwrite the Aimeos.Product.Selection.init() method in your custom.js file
Professional support and custom implementation are available at Aimeos.com
If you like Aimeos, Image give us a star

jafo66
Posts: 65
Joined: 06 Mar 2024, 04:42

Re: Show Product Subparts only for certain types of products

Post by jafo66 » 27 Jul 2024, 19:40

This doesn't seem to be working, did I miss understand your reply?

Code: Select all

const origInit = Aimeos.Product.Selection.init;

Aimeos.Product.Selection.init = () => {
	console.log('Yes, the override worked');

	const tab = $(".item-navbar .selection");
	['tournament', 'group', 'select'].includes($(".item-basic .item-type").val()) ? tab.show() : tab.hide();

	$(".item-product").on("change", ".item-basic .item-type", function() {
		['tournament', 'group', 'select'].includes($("option:selected", this).val()) ? tab.show() : tab.hide();
	});
};

jafo66
Posts: 65
Joined: 06 Mar 2024, 04:42

Re: Show Product Subparts only for certain types of products

Post by jafo66 » 27 Jul 2024, 19:47

here is my manifest file:

Code: Select all

{
	"projectName": "tournament-management",
	"licenseText": "proprietary",
	"pkgs": [{
		"name": "tournament-management CSS",
		"file": "index-css",
		"isDebug": true,
		"fileIncludes": [{
			"text": "custom.css",
			"path": "themes/admin/jqadm/"
		}]
	}, 
	{
		"name": "tournament-management JS",
		"file": "index-js",
		"isDebug": true,
		"fileIncludes": [{
			"text": "custom.js",
			"path": "themes/admin/jqadm/"
		}]
	},
	{
		"name": "CYBN Components",
		"file": "components-js",
		"isDebug": true,
		"fileIncludes": 
		[{
			"text": "searchable-select.js",
			"path": "js/components/"
		},
		{
			"text": "cybn-select.js",
			"path": "js/components/"
		}]		
	} 	 
],
	"resources" : []
}


jafo66
Posts: 65
Joined: 06 Mar 2024, 04:42

Re: Show Product Subparts only for certain types of products

Post by jafo66 » 28 Jul 2024, 02:32

Nevermind... I had to force a hard reload on the page and then it worked properly.

Post Reply