Set default values for attributes

Hello,

when there is a “non editable” attribute on front-end, would be interesting to have the option to define the attribute or one of it`s options as default.

Let`s say I have an attribute non editable on front end, that has 2 options and I would like one of it to be default. It is not possible.

Right now when the vendor creates the new account we must manually select the option for each vendor.

Since it is an attribute not editable for the vendor, it would make sense for the admin to be able to have default attributes.

In my real case scenario, it is something like all vendors start with “Pending Verification” on profile, but could be any lable, like “Silver Member” before change manually to “Gold Member” or anything after the vendor do some action, like verifies profile, pay something, etc.

Of course would be amazing in future if it was possibile to change automatically some attribute option based on actions, like if vendor creates a listing on some category another attribute is given automatically, but right now I would be happy with the default attribute from the admin option.

Thanks

Thanks, we’ll consider adding this feature. There’s a temporary PHP snippet that you can use to set the default value for a selectable vendor attribute:

add_action(
	'hivepress/v1/models/vendor/create',
	function ($vendor_id, $vendor){
		$vendor->set_vendor_default_rate(123)->save_vendor_default_rate();
	},
	1000,
	2
);

Please replace 123 with the option ID (you can check it in the browser address bar while you edit and option).

Thanks Ihor,

now it worked! Also needs to substitute attribute name

add_action(
	'hivepress/v1/models/vendor/create',
	function ($vendor_id, $vendor){
		$vendor->set_vendor_default_rate(123)->save_vendor_default_rate();
	},
	1000,
	2
);

Replace 123 with the option ID (you can check it in the browser address bar while you edit and option).

Replace vendor_default_rate with specific attribute name

1 Like