Created
April 26, 2022 17:29
-
-
Save hivepress/445d4fccae06a512f5410f28689e1b67 to your computer and use it in GitHub Desktop.
Make the price field optional for marketplace listings #hivepress #marketplace
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| add_filter( | |
| 'hivepress/v1/models/listing/attributes', | |
| function( $attributes ) { | |
| if ( isset( $attributes['price'] ) ) { | |
| $attributes['price']['edit_field']['required'] = false; | |
| } | |
| return $attributes; | |
| }, | |
| 1000 | |
| ); |
Author
This would require further customizations, probably for the hivepress/v1/models/listing/fields hook instead, because the attributes hook has no parameters for changing the field behavior depending on categories.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for this.
Suppose we want it to be Required only for a few categories and Optional for a few other Categories, how can we do this ?
Someone in the community please help. Thanks.