Custom attribute value in menu to display product archive
-
Trying to do the same functionality as in the ‘All Schools’ menu at collegelogostuff.com.
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 a custom global attribute with ‘Enable Archives’ box checked, 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, Army West Point, and Auburn, 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 upon selecting any school, only data from the default main product displays in the archive page, and none of the variable product data for all the school variations displays here.
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.
Per instructions given here: https://docs.woocommerce.com/document/using-custom-attributes-in-menus/1- Added following code to my child theme functions.php:
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;
}2- Copied woocommerce/templates/taxonomy-product_cat.php into my child theme folder and renamed template to mychildtheme/woocommerce/taxonomy-pa_find-your-school.php
Then I cleared my varnish cache and refreshed the site several times but no change. Both schools, Arizona State and Army West Point still display Air Force Academy products.
Will someone please help me display archive pages with products associated with the custom attribute value only?
Thanks much,
Mark
[email protected]
- The topic ‘Custom attribute value in menu to display product archive’ is closed to new replies.