i want to set a default price for new products. what i have is a field
for price in my new products form which obviously if you add a price
into it that is easily saved.
but what i want is a way for, if the field is left blank (in my case i
will not be showing this field to users who are given an option to
create own product) but i want a default price to apply, lets say 2.55,
to that product on save. so if they add their product to cart the price
is read in.
so some code to say if price is left blank, price is 2.55, on save. but
i’m having trouble and dunno ow to do it correctly. also whether code
should go in the model or controller or both.
the products this is applying to is all products created by other users,
except the admin user(user_id=1] who fills in price. so maybe could say
if current_user is not admin, price is saved as 2.55 for each product
created? not rly sure how to write it correctly.
similarly, i want the same for user_id field i have. i want whoever is
logged in creating the product, there user_id to apply to the new
product. which at the minute isn’t working either.
any help appreciated. thanks!