Multi Vendor Marketplace Plugin | WCFM Marketplace › Forums › WCFM – Marketplace (WooCommerce Multivendor Marketplace) › Allow only one attribute for product
- This topic has 11 replies, 3 voices, and was last updated 4 years, 8 months ago by contatoapp.
- AuthorPosts
- March 6, 2020 at 2:50 am #110155contatoappParticipant
I’d like to know if it’s possible to store vendors to add only one attribute to their products. I could use CSS to hide the “Add all” button but they can still open the dropdown menu and add another attribute. The specified attributes refer to the items condition (mint, near-mint, used) so users could filter products on my marketplace by their condition, but I don’t want store vendors to add several attributes cause it wouldn’t make any sense.
Attachments:
You must be logged in to view attached files. - March 6, 2020 at 4:16 pm #110260SushobhanKeymaster
Hello,
Kindly use the following snippet-add_filter( 'wcfm_attribute_limit', function( $limit ) { return 1; } );
Add this code to your child theme’s functions.php
In case you do not have child theme then add code using this plugin – https://wordpress.org/plugins/code-snippets/ - March 9, 2020 at 7:49 pm #110729contatoappParticipant
Hi. I’ve used Code Snipepts to add this code but vendors are still able to add more than one attribute. Please see the attached screenshots:
Attachments:
You must be logged in to view attached files. - March 10, 2020 at 5:25 pm #110944SushobhanKeymaster
Hello,
It seems the product is already published before the code snippet was added. From now on, when you try to add a new product, you will see that you can’t add more than one attribute.
Thanks! - March 10, 2020 at 8:15 pm #110974contatoappParticipant
Hi. I’ve published another product and I’m still able to add more than one attribute. Please see screenshots.
Attachments:
You must be logged in to view attached files. - March 11, 2020 at 3:05 pm #111165SushobhanKeymaster
Hello,
Have you use my snippet in your themes function.php? Well, the snippet should work. To debug this further I’ll require a temporary access of your site. When sharing the access, please don’t forget to mark the reply as private.
Thanks! - March 11, 2020 at 8:27 pm #111226contatoappParticipantThis reply has been marked as private.
- March 12, 2020 at 12:35 pm #111302Sarmistha ChakrabortyMember
Hello,
We have disabled the “Mandatory attributes” snippets.(PFA)
This code is creating the issue.Now is working fine.Thanks.
Attachments:
You must be logged in to view attached files. - March 12, 2020 at 11:02 pm #111383contatoappParticipant
Hi. It’s good that is working now, but I also deemed that snippet necessary. That way vendors wouldn’t create a product without selecting an attribute. Is there no way to allow only one attribute and also make it required that vendores add an attribute?
- March 16, 2020 at 5:26 pm #111834SushobhanKeymaster
Hello,
Kindly use the following snippet instead-add_filter( 'wcfm_product_custom_attributes', function( $taxonomy_fields, $att_taxonomy ) { if ( isset( $taxonomy_fields[$att_taxonomy] ) && isset( $taxonomy_fields[$att_taxonomy]['options'] ) ) { if ( isset( $taxonomy_fields[$att_taxonomy]['options']['is_active'] ) ) { $taxonomy_fields[$att_taxonomy]['options']['is_active']['custom_attributes'] = array( 'required' => 1, 'attrlimit' => 1, 'required_message' => 'Attributes are required' ); } if ( isset( $taxonomy_fields[$att_taxonomy]['options']['value'] ) ) { $taxonomy_fields[$att_taxonomy]['options']['value']['custom_attributes'] = array( 'required' => 1, 'attrlimit' => 1, 'required_message' => 'Attributes are required' ); } } return $taxonomy_fields; }, 50, 2 );
Thanks!
- March 16, 2020 at 6:01 pm #111840contatoappParticipant
Hi. Could you check my question down below about translating the “You can only select 1 item” string when adding attributes?
- March 14, 2020 at 12:58 am #111514contatoappParticipant
Also, where can I translate this string? I’ve found the exact same one on Loco Translate for WCFM – WooCommerce Frontend Manager but it did not apply for this message.
Attachments:
You must be logged in to view attached files.
- AuthorPosts
- You must be logged in to reply to this topic.