Home › Forums › WoodMart support forum › Getting error from the swatches module
Getting error from the swatches module
- This topic has 9 replies, 2 voices, and was last updated 5 years, 10 months ago by Artem Temos.
-
AuthorPosts
-
January 31, 2019 at 1:58 am #105062
dotcominfoParticipantI’ve obtained another license for a new site I’m building for a medical products manufacturer, and I’m re-themeing their existing site with WoodMart, which means all the product data was originally set up with another theme. I don’t know if that has anything to do with the error I’m getting. I just wanted to give you a little background.
I checked all settings that have anything to do with swatches and it’s all turned off. So… I need your help in figuring out how to solve this error (what’s causing it – how to get rid of it).
Here’s the error:
Warning: Invalid argument supplied for foreach() in /home/svsimage/public_html/dsc/wp-content/themes/woodmart/inc/integrations/woocommerce/modules/swatches.php on line 277Thank you!
January 31, 2019 at 5:55 am #105068
Artem TemosKeymasterHello,
Thank you so much for purchasing our theme and contacting our support center.
Try to add the following PHP code snippet to the child theme functions.php file to fix this
function woodmart_get_active_variations( $attribute_name, $available_variations ) { $results = array(); if ( ! $available_variations ) { return $results; } foreach ( $available_variations as $variation ) { $attr_key = 'attribute_' . $attribute_name; if ( isset( $variation['attributes'][ $attr_key ] ) ) { $results[] = $variation['attributes'][ $attr_key ]; } } return $results; }
Kind Regards
XTemos StudioJanuary 31, 2019 at 6:17 pm #105218
dotcominfoParticipantI tried doing this – but there was a problem. WordPress said:
Your PHP code changes were rolled back due to an error on line 19 of file wp-content/themes/woodmart-child/functions.php. Please fix and try saving again.
syntax error, unexpected ‘if’ (T_IF)
January 31, 2019 at 7:11 pm #105222
Artem TemosKeymasterPlease, send us your admin and FTP access so we can check it.
January 31, 2019 at 9:08 pm #105244
dotcominfoParticipantHere you go. (in the private content)
February 1, 2019 at 6:56 am #105262
Artem TemosKeymasterHi,
We have added the code and there is no more error now.
Regards
February 1, 2019 at 4:51 pm #105384
dotcominfoParticipantFantastic! What was the syntax error in the code? Just curious.
Thank you for the great support.
February 1, 2019 at 7:53 pm #105417
Artem TemosKeymasterWe didn’t change anything, just copy and paste the code 🙂
February 1, 2019 at 7:55 pm #105419
dotcominfoParticipantMust have been something about my cut and paste activity. I tried doing it from the admin (Appearance > Editor) and that’s where I got the message that I forwarded to you.
I then also tried applying your snippet to the functions.php file in the child theme using FTP. That didn’t fix it either. I wonder if copying it from the webpage on this thread had anything to do with it. Strange…
Oh well. Thanks for the support!
February 2, 2019 at 9:41 am #105474
Artem TemosKeymasterYou are welcome!
-
AuthorPosts
- You must be logged in to create new topics. Login / Register