WCMp Core
-
AuthorPosts
-
-
November 23, 2023 at 3:54 PM #214143embpriParticipant
Hi,
All products on my marketplace are virtual and downloadable, but when Vendors upload their products they sometimes get confused because they first need to check those boxes (see attached) before they can upload a file.
Could you please tell me a way I can have those boxes be checked by default? If there is a way to have them be checked by default, I will even use CSS to hide them so that Vendors are not confused.
Please take a look at the attached screenshot and tell me how I can make these two checkboxes be checked by default, and the “Downloadable files” section always visible.
Thank you. 🙂
-
November 23, 2023 at 5:28 PM #214155Sangita Support SquadKeymaster
Hello @embpri, You can add the below code in the functions.php file of your current active theme to have the virtual and downloadable box be checked by default.
add_filter( 'mvx_product_type_options', 'autocheck'); function autocheck( $options ){ $options ['virtual']['default'] = "yes"; $options ['downloadable']['default'] = "yes"; return $options; }
Copy -
November 24, 2023 at 1:51 AM #214171embpriParticipant
Thank you very much, this works perfectly!
I just had one last question: is there a way for me to make adding at least one download to the product compulsory? I don’t want vendors to be able to save/publish their products without adding at least one download to it.
Thanks. 🙂
-
November 24, 2023 at 2:45 PM #214228Sangita Support SquadKeymaster
Greetings @embpri!
The modification you are looking for is not supported by our default flow. You will have to implement your desired flow on your end by adding custom code.
If you need help with reference hooks/filters please let us know. -
November 30, 2023 at 12:38 PM #214591embpriParticipant
Hi,
The filter that you provided was perfect, with some additional JS I was able to solve the issue, so please mark this ticket as closed.
For anyone that has the same or a similar requirement, here’s how I solved it on my site.
jQuery(document).ready(function() { jQuery.when(jQuery('a.btn:nth-child(1)').trigger('click')).done(() => { document.querySelector('.file_name > input:nth-child(1)').required = true; document.querySelector('tbody.ui-sortable > tr:nth-child(1) > td:nth-child(3) > input:nth-child(1)').required = true; }); });
CopyI used jQuery to automatically click the “Add File” button in the download section and make the resulting “File Name” and “File Link” fields required by the browser.
-
November 30, 2023 at 4:14 PM #214620Sangita Support SquadKeymaster
Thanks @embpri, for helping out the community.
-
-
AuthorPosts
The topic ‘Have “Virtual” and “Downloadable” options required and checked by default’ is closed to new replies.