Select custom attribute value in menu to display product archive
-
Upon selecting a custom attribute value in the menu, I want to display archive pages with products associated with the custom attribute values only.
For example, when a user selects ‘Arizona State’ in the ‘Find Your School’ menu, an archive page displays all products associated with Arizona school only.
In my dev site at https://affinitygamerooms.marklovettstudio.com/ , I set up ‘Pool Tables’ as a variable product, ‘Find Your School’ as an attribute, and schools are entered as attribute values. I created many other variable products using the same 60 schools as custom attribute values.
To test, I have entered data in the first three schools only …. Air Force Academy, Arizona State and Army West Point, the other schools are empty.
When user selects a school in the “Find Your School’ menu, I want to display only products associated with the particular school, however now, upon selecting ‘Arizona State’, although the permalink is ‘https://affinitygamerooms.marklovettstudio.com/pa_find-your-school/arizona-state-university/’ , products display in an archive page from Air Force Academy.
Similarly, when I select the ‘Army West Point’ from the ‘Find Your School’ menu, the permalink appears correct, https://affinitygamerooms.marklovettstudio.com/pa_find-your-school/army-west-point/, however the products that display are for Air Force Academy as well.
The code I added to my child theme functions.php is:add_filter(‘woocommerce_attribute_show_in_nav_menus’, ‘wc_reg_for_menus’, 1, 2);
function wc_reg_for_menus( $register, $name = ” ) {
if ( $name == ‘pa_find-your-school’ ) $register = true;
return $register;
}Will someone please help me display archive pages with products associated with the custom attribute value only?
Thanks much,
Mark
[email protected]
- The topic ‘Select custom attribute value in menu to display product archive’ is closed to new replies.