i have a product which can be customized by the user. ie: he can add some free text on both sides of the medal, added by a nice gravur.
what would be the best way to build this – maybe its a little bit dificult
should i add 2 fields to spree_line_items: “custom_front” and “custom_back”
and add a field to the product to check if it can be customized?
is that the best way?
amd seriously, i dont know why stackoverflow means, that these question doenst meet the quality standards. lol
First, I’d add a boolean field to the products table to identify whether or not products can be personalized.
Next, I’d recommend creating a new custom model that contains personalizations and belongs_to line items.
A “personalizations” table would contain fields id, line_item_id, custom_front, and custom_back.
You will have to override the product page to show the text fields for custom_front and custom_back when is_personalizeable is true.
Also, when an item is added to the cart, you’ll have to add a callback to insert into the Personalizations table (if product can be personalized) and tie it to the line item. You’ll likely have to override Spree’s core add to cart methods here.
I’m recommending this method because: