I am building an internal CRM with toolset and am stuck on how to organise some data correctly.
The part I am struggling with is a 'product' custom post type which is used to store the company sales products.
The company sells kitchen cabinets and each cabinet has multiple variations in size (mainly widths of 300,400,500,600,700,800,900,100mm). Each cabinet is also available in 55 different colours.
My problem comes in how to assign relationships between each size / colour when the product is assigned to an order for a customer.
My current relationship structure is as follows. (the '' terms are custom post types)
Each 'customer' has a one to many relationship with a 'quote' or 'contract' (I/e the company provides many quotes or contracts to 1 customer.)
Each 'quote' or 'contract' has a many to many relationship with a 'product' (ie products can be assigned to many quotes or contracts)
The idea is that I will create a new quote (front end or backend) for a customer, assign the products to this quote and send the contract to the customer for signing etc.
What would be the best way to structure the products that I can easily form a new 'quote' and add the products. Is my variation of each product thinking the best way, or should I create a new product per variation to make things cleaner and easier?
(the site is custom and will be preferably written using the apis / php available as opposed to views)
This is a subjective issue and there are more than one possible ways that you can manage product variations,.
However, I see your request as no different than how WooCommerce manages the product variations, where each of the product variation are stored as a separate products linked to a parent product, In this way with the Many to Many relation with Orders and Products you can easily map the variation products for each orders also you can have more than one variation for each order. Creating the variations as separate products makes it is easy to query for other use cases.
You can refer to this write up on how product variations are managed in WooComerce : hidden link
Would you therefore suggest creating separate products in the admin or use a repeatable post group since these are essentially separate posts, albeit under a hidden post type which can still be queried on the front end?
I am not exactly sure how repeatable field groups can help here as you cannot have a direct relation with orders post type and Repeatable field group of a product post type. I hope you get what i mean ?