Linking WC Products by Attribute Within the Same Product Family

The code in this download folder enables you to link products by attribute within the same product family. In this case, we link products by size together.

Example : You’ve created a new product for every size, red dress size 1, red dress size 2, red dress size 3 and you need to add the size links to each so red dress size 1, 2 & 3 link together. However, you also have other products like blue dress size 1, blue dress size 2 and blue dress size 3 and you need these linked together so all red dresses and all blue dress are linked but you don’t want red dresses linked to blue dresses.

To make this happen, we add 2 custom fields to the general tab. The 1st for the shared attribute which in this case is size and the 2nd for the product family. This way only products in the same group link together and not products in another group with the same size. Here’s an example you can see work in the demo video :

All you need to do is add the size and unique product family or group name.

Video Demo

Shows same sizes added to different colored dresses so all sizes for a specific red dress are linked together and all sizes for a specific orange dress are linked together.

Tested in WooCommerce using simple and bookable products.

Installation

There’s 2 steps :

  1. Copy and paste the PHP code to the end of your child themes functions file.
  2. Optional : Copy and paste the CSS to the end of your child themes style.css file or additional CSS field if using block themes.

Download Folder

Related Tutorials

Was This Tutorial Helpful?

Free

$0

Access only to all free tutorials per month.



Monthly

$75

Access to 10 premium tutorials per month.


Tutorial Request


Includes code guarantee and coding support.

Yearly

$500

Access to 15 premium tutorials per month.


Monthly Tutorial Request


Includes code guarantee and priority coding support.