Product Price/Variant matrix (hundreds of possible prices)


#1

Hello Reactioneers!

I’m planning out a product pricing/variant feature for a blinds shop and wanted your feedback. When ordering a blind online, you can customize the size by height and width up to 32" and in variants of 1/8" for each, resulting in hundreds of possible options. The 2d pricing matrix looks something like this:

						WIDTH								
36	48	60	72	84	96	108	120	132	144	156	168	180	192	VANE
36	153	197	226	260	265	278	313	349	384	404	451	466	509	536	4
48	162	207	232	268	273	293	320	355	391	419	487	501	529	557	5
60	170	213	237	278	283	300	334	384	424	460	509	521	557	585	6
72	178	218	241	287	293	320	355	406	446	487	521	544	592	627	7
84	185	224	245	294	307	349	384	430	487	515	570	592	639	674	8
96	192	228	251	303	320	369	419	461	521	557	611	639	681	709	9
108	207	244	272	313	355	391	446	487	557	592	654	681	738	779	10
120	215	257	293	334	375	424	474	521	579	627	698	709	772	835	11
132	220	266	300	355	391	446	501	544	606	669	738	759	821	877	12
144	228	281	313	369	419	474	521	570	654	698	772	808	864	932	13

You can see something similar to what the end product may look like at JustBlinds.com here:


My current thinking is to, at a high level, programmatically create a product variant per possibility and then hide it behind the scenes and selecting it once a high and width value is chosen. I simply wanted to check if creating these hundreds of product variants was the best way to go about it and if so, if any advice may be given for implementation planning.

I’ve started on frontend for it and have the height and width option fields ready:

Thank you for considering my task and for any advice given.

Kind Regards,
Michael D Mooring

:bow:


#2

You should be fine with creating all those possible variants and hiding them behind the scenes. Then, when the customer selects their desired sizes, you can then add that exact variant to the cart for them.


#3

Thanks @mike

Alright after reading the docs further I see an implementation approach with the Product Variants API:

  1. Create the variant folding the child variants (the 100+ height/width possibilities):
    createVariant(products/createVariant, productId);
  2. Loop through creating the child variants:
    Meteor.call("products/cloneVariant", productId, variantId, parentId);

#4

So I have the How, but the When and the Where is what I’m trying to figure out on my commute back home on the train. I’m new to Meteor so should I be creating my 182 child variants using:

  • Template events ?
  • Template helpers ?
  • or maybe somewhere in the database schemas that Meteor uses so that when the variantType (something I added in the schema) is of heightWidth, then spawn the variant with these 182 child variants ?
  • or a mix of these ?

#5

There’s a couple of different ways you could do that but you might want to do something like this and just add a function to do what you want (with a check if it already ran).