rudy
July 29, 2022, 3:11pm
1
Hello, in hivepress settings for the selling, I checked the
“Require file attachments” because I need vendors to be able to sell ebooks on my category Ebooks.
But for other categories makes no sense in my marketplace to have a file attachment as required.
Could this item be optional or can I only restrict it to the category ebooks?
Thanks
rudy
July 30, 2022, 2:50pm
4
If it can help someone, to make file attachment optional, this is the snippet
<?php
add_filter(
'hivepress/v1/models/listing/attributes',
function( $attributes ) {
if ( isset( $attributes['attachments'] ) ) {
$attributes['attachments']['edit_field']['required'] = false;
}
return $attributes;
},
1000
);
Is it possible to chose wich categories have the file attachment?
2 Likes
ihor
July 30, 2022, 4:50pm
5
1 Like
rudy
July 30, 2022, 5:08pm
6
Hi Ihor,
Is it possible to chose wich categories have the file attachment?
thanks
yevhen
July 31, 2022, 7:57pm
10
Please try this PHP snippet but please note that it needs additional testing. Please change 1,2,3 on the categories id where you want to show this field
add_filter(
'hivepress/v1/models/listing/attributes',
function ($attributes){
if(isset($attributes['attachments'])){
$attributes['attachments'] = array_merge($attributes['attachments'], ['categories' => [1,2,3]]);
}
return $attributes;
},
1000
);
4 Likes
system
Closed
August 30, 2022, 10:12pm
12
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.