Setting Up Grouped Products in WooCommerce
- July 7, 2017
- Leave a comment
WooCommerce provides different options to manage products. One of the best options is “Grouped Products“. Using grouped products feature, you can make linked products accessible to the users in order to avoid the hassle of browsing each product separately. In this article, you will learn how to set up grouped products in WooCommerce.
You can increase the sale of your products in an easy way by setting up WooCommerce Grouped Products. For now, let’s suppose the following scenario that you have:
- Laptop in Computers category
- Webcam and Wireless Mouse in Accessories category
- Computer Table and Chair in Furniture Category
All the above mentioned products are related to different categories. Users have to browse these products either individually or category wise. A user purchasing a Laptop might need other things as well. If he/she can’t see them, they might skip them.
To resolve this issue, change the “Product Data” option on “Edit Product” page of the WordPress admin panel and select “Grouped Product” option from the drop down list of options. By doing so, the product price will be disabled.
Now, select the “Linked Products” option. Another option with the title “Grouped Products” will appear. From here, select the grouped products by typing products names. Those products will now appear on the main product page. As in our case, consider a Laptop and all the other products mentioned above. You either have to insert the Laptop (product name) again or create a new product (and set it as a Grouped Product). Now, select the Laptop and other products (webcam, wireless mouse, computer table and computer chair) in Linked Products Tab.
The grouped product is ready now. Browse the product on front-end and see other Linked Products list on that page along with their prices. Also, you can select quantity for each product.
Select the required quantity of products accordingly and then click on “Add to Cart” button (placed under the linked products list). Now, all the selected products are added to the Cart.
After that, go to the WooCommerce Cart page to see all the selected products in Cart list as individual products.
Grouped Products in the Database
So far, the Grouped Products are discussed in terms of administrator and client/purchaser context. In this section, you will learn how the Grouped Products are linked with the parent/main product.
After converting a Simple Product into a Grouped Product, go to PHPMyAdmin and see what has happened with the main product. Assuming the Product ID is 104, execute the following query:
SELECT * FROM `wp_postmeta` WHERE post_id=104
It will display all the results having meta_key=’ _children’ and a serialized array of linked products’ IDs.
Access WooCommerce Grouped Products via Code
Although WooCommerce API has a good documentation but to make it easy for you, use the code given below to access Linked Products in WooCommerce:
$product_id = 104;
$product = get_product( $product_id );
$children = $product->get_children();
print_r($children); // Array of IDs of products linked to Group product