Home › Forums › WoodMart support forum › Swatches not showing on shop/search results
Swatches not showing on shop/search results
- This topic has 9 replies, 3 voices, and was last updated 7 years, 1 month ago by
Artem Temos.
Viewing 10 posts - 1 through 10 (of 10 total)
-
AuthorPosts
-
January 22, 2018 at 8:31 pm #34843
ruandeyzelParticipantPlease have a look on https://legwearsafari.co.za/staging and search for “Falke High School Opaques” – some swatches are missing, but does appear to be there when going into the single product.
January 23, 2018 at 7:27 am #34868
Eric WatsonParticipantHello,
Could you please provide us your admin so we can check what is wrong there?
Kind Regards
XTemos StudioJanuary 23, 2018 at 8:01 am #34884
ruandeyzelParticipantHere you go
January 23, 2018 at 8:45 am #34921
Artem TemosKeymasterPlease, provide us your FTP access also.
January 23, 2018 at 9:09 am #34927
ruandeyzelParticipantFTP
January 23, 2018 at 10:36 am #34953
Artem TemosKeymasterTry to add the following PHP code snippet to the child theme functions.php file to fix this
function woodmart_swatches_list( $attribute_name = false ) { global $product; $id = $product->get_id(); if( empty( $id ) || ! $product->is_type( 'variable' ) ) return false; $available_variations = $product->get_available_variations(); if( ! $attribute_name ) { $attribute_name = woodmart_grid_swatches_attribute(); } if( empty( $available_variations ) ) return false; $swatches_to_show = woodmart_get_option_variations( $attribute_name, $available_variations, false, $id ); if( empty( $swatches_to_show ) ) return false; $out = ''; $out .= '<div class="swatches-on-grid">'; $swatch_size = woodmart_wc_get_attribute_term( $attribute_name, 'swatch_size' ); if( apply_filters( 'woodmart_swatches_on_grid_right_order', true ) ) { $terms = wc_get_product_terms( $product->get_id(), $attribute_name, array( 'fields' => 'slugs' ) ); $swatches_to_show_tmp = $swatches_to_show; $swatches_to_show = array(); foreach ($terms as $id => $slug) { $swatches_to_show[$slug] = $swatches_to_show_tmp[$slug]; } } $swatches_to_show = array_filter( $swatches_to_show, function($value) { return $value !== ''; }); foreach ($swatches_to_show as $key => $swatch) { $style = $class = ''; if ( empty( $swatch ) ) continue; if( ! empty( $swatch['color'] )) { $style = 'background-color:' . $swatch['color']; } else if( ! empty( $swatch['image'] ) ) { $style = 'background-image: url(' . $swatch['image'] . ')'; } else if( ! empty( $swatch['not_dropdown'] ) ) { $class .= 'text-only '; } $style .= ';'; $data = ''; if( isset( $swatch['image_src'] ) ) { $class .= 'swatch-has-image'; $data .= 'data-image-src="' . $swatch['image_src'] . '"'; $data .= ' data-image-srcset="' . $swatch['image_srcset'] . '"'; $data .= ' data-image-sizes="' . $swatch['image_sizes'] . '"'; if( woodmart_get_opt( 'swatches_use_variation_images' ) ) { $thumb = wp_get_attachment_image_src( get_post_thumbnail_id( $swatch['variation_id'] ), 'shop_thumbnail'); if ( !empty( $thumb ) ) { $style = 'background-image: url(' . $thumb[0] . ')'; $class .= ' variation-image-used'; } } if( ! $swatch['is_in_stock'] ) { $class .= ' variation-out-of-stock'; } } $class .= ' swatch-size-' . $swatch_size; $term = get_term_by( 'slug', $key, $attribute_name ); $out .= '<div class="swatch-on-grid woodmart-tooltip ' . esc_attr( $class ) . '" style="' . esc_attr( $style ) .'" ' . $data . '>' . $term->name . '</div>'; } $out .= '</div>'; return $out; }
January 23, 2018 at 12:21 pm #34974
ruandeyzelParticipantWill this fix also be in the next update?
January 23, 2018 at 12:23 pm #34978
Artem TemosKeymasterYes, we will include it in the next update.
January 23, 2018 at 1:19 pm #34995
ruandeyzelParticipantAwesome thanks for the help
January 23, 2018 at 1:20 pm #34996
Artem TemosKeymasterYou are welcome!
-
AuthorPosts
Viewing 10 posts - 1 through 10 (of 10 total)
- You must be logged in to create new topics. Login / Register