Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

MahmoudMonem's avatar

[Discussion] Best approach to handle bundle products/packages

Hello Guys, I was wondering what is the best way to create bundle of existing products. what approach do you follow. do you create a separate bundles table or you just handle everything in blade view or you just add new columns to the existing product table.

now for example we have :

Product 1 : price : 50 USD Product 2 : price : 100 USD

If I would like to create something like

Buy Product 1 + Product 2 for 120 USD, what is the best way to achieve that.

0 likes
9 replies
bugsysha's avatar

I create a bundle_product pivot table and put the price on the bundle table. No logic should be in blade files. To blade files you only send what it needs to display.

1 like
MahmoudMonem's avatar

Hey @bugsysha .. thanks for your input but i am kinda confused .. can u plz elaborate more .. so you would have 1- product table .. 2- bundle table .. 3 - bundle-product table ?? .. what would be stored in the bundle table and the pivot one

bugsysha's avatar

In the bundle table you can store price, title, description and what else makes sense.

Snapey's avatar

You could have just a single 'bundle' table - it depends if you need to store other data about the bundle.

In a product record, have a 'isBundle' column.

in bundle table, have an id column, a product_id and a related_id

Create a product that describes the bundle, sets its price, shipping costs etc etc Set the isBundle to true

Create entries in the bundles table, each entry points to the bundle master product and the related product that is in the bundle.

bugsysha's avatar

related_id points to the id on the bundles table?

Snapey's avatar

no, i was thinking, a master product, and then a table that links master product to other products.

I suppose it could be a pivot table but both product_id and related_id point to the same products table

Thinking after, the thing that is missing is knowing which bundles are to be shown on which pages

bugsysha's avatar

Yeah, pretty much the same with specifics that can be added to bundle or pivot table.

chiefguru's avatar

We approach it slightly differently, our products table has a bunch of flags, one of which is can_be_bundled, we use that to apply a bundle discount to the product when it's added to the cart with something else.

siangboon's avatar

Just as Snapey suggested, a "bundle" table with some fields such as description, price, discounts, etc relevant information will be enough, but I would probably use a json, array to store the list of product id in this bundle instead of a pivot table and "isBundle" flag in product table may and may not necessary, it depend on how you design it.

Please or to participate in this conversation.