All things Shopify and commerce
Ok, I've been searching and trying to figure this out. I've added metafields to custom data and some other place but I'm still not seeing how to accomplish this so reaching out for help.
I have a lot of products that have primary and secondary color options. The category these products are under only has one metafield and it is Color. Works great for the primary color and I like how I can closely represent what the color actually is. However, for the secondary color, there's no metafield to associate with so those colors are just text.
So, is there a way for me to create another metafield just like the Color metafield so things look uniform on the page?
I appreciate any help with this and hope there's a simple solution to this.
This depends on the theme you are using. Some themes have relevant settings. If the theme you are using does not have such settings, you can only modify the theme code.
Hi BradgetDesigns,
Just like how you added the first color metafield, you can add a second one. I just tested it myself right now and I was able to add two color metafields to products.
Hope this helps! And if you have any questions, feel free to let me know 🙂
Well, the first metafield is associated with the category. I didn't add it. So, when I try to associate the second variant to a metafield I get the message that no metafields are available.
Also, looking at your image, that's a product metafield which I don't think I've tried. I was trying a variant metafield so perhaps that's where I was getting hung up. So are you saying that two different product metafields can be associated with two variants? I'll mess with that a bit.
I added a product metafield and it appears here (first image) but I still cannot associate it with the variant (second image) because that little hamburger icon seems to only associate with category metafields.
Oh, okay. I understand. Thanks for clarifying it!
Unfortunately, there is no way to control what metafields gets created by the category right now - not sure if that's going to change in the future.
An alternative would be to use variant metafields. In the variant metafields, you'll use the type of color, just like my first comment. Then set the color's value inside the variant metafield.
Say you have a red variant, the value of its color metafield would be the red color. More samples
Then, in order for it to display just like the category metafield in the product page, your theme's code will be changed. No other way around that unfortunately 😬
Ok. But I've tried variant metafields and can't figure out where to associate them with the variants. Or is that on an individual, one by one variant thing? Seems like a pain. I've also noticed some products that just use the color metafield fail horribly (below). It seems like a great way to show colors for variant options since I haven't figured out another "simple" way to do this but it's turning into more of a hassle if things like this are going to happen.
Or is that on an individual, one by one variant thing?
Unfortunately, yes. 😬
I think. Wait. There's another way to do it, using metaobjects. You're still going to set it in the variant's metafield but no need for you to repeat adding the color's values.
Hmm, I went back and reread your previous post and see what you are saying I think but I also don't want to get to far into editing code. I'm not afraid of it but I'm horrible about keeping notes and when a new version of the theme (Refresh currently) comes out, I don't want to chase my tail trying to fix stuff again.
That said, I'll look into meta objects. I haven't gone that route yet. I'm still trying to wrap my head around this whole metafield/metaobject thing and how it works. It just seems like a simple thing that if you have a product with multiple color variants, you should be able to display those colors multiple times without making it difficult or having to have an image of every possible color combination to assign it to each variant combination.
Maybe I'm just misusing this whole thing and should just have color swatch images for each color... actually, that wouldn't work I don't think either.
This is how it would work with metaobjects.
Looks messy if you try to imagine the entire structure, but I guarantee you that it's very easy to set up and edit.
Yeah, the pains of dealing with code is very relatable. I understand.
If you need help with set up and coding, I'd be happy to do it for you for a fee. I'll set up the metaobjects, variant metafields, edit the code of the selector. That way, all you'll need to do is to create the variants and connect it just with few clicks, then your secondary color variants will display just like the primary color. I could also write you instructions so that if your theme updates, you can set it up easily yourself. If you're interested, feel free to let me know. 🙂
I appreciate the help, truly. So are you saying that a listing that looks like this (first image) would then look like this (second image...appreciate my MS Paint skillz)? I'm trying to think about how much this would take to keep up and such as well since the variants can change from product to product. And, there's still the issue I posted where on some products even the Category metafield isn't displaying correctly which makes this whole venture a bust.
Yes, you got that right.
Set up would be easy because we're using metaobjects and connecting it would be just a few clicks. It will just be a pain to connect one by one but there's no other way to go around that. Coding, a pain too.
As for products where the category metafield isn't available, I'm not 100% sure if using two variant metafields (Primary and Secondary colors) would work but I honestly would love to give it a go.
The MSPaint edit looks sleek 😎
Were you able to get this to work? i have a need for three color selections for a product.
Starting a B2B store is a big undertaking that requires careful planning and execution. W...
By JasonH Sep 23, 2024By investing 30 minutes of your time, you can unlock the potential for increased sales,...
By Jacqui Sep 11, 2024We appreciate the diverse ways you participate in and engage with the Shopify Communi...
By JasonH Sep 9, 2024