Skip Navigation

[Résolu] Best Approach for WooCommerce Product child & grandchild post types

Ce fil est résolu. Voici une description du problème et la solution proposée.

Problem: Best Approach for WooCommerce Product child & grandchild post types

Solution: I suggest to have a one to many relationship setup between Vendor (parent) and Product (child). And then with vendor post type - add the post reference field to connect vendor child to it.

you can find proposed solution, in this case, with the following reply: => https://toolset.com/forums/topic/best-approach-for-woocommerce-product-child-grandchild-post-types/#post-1094856

Relevant Documentation: => https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/using-post-reference-fields-to-display-information-from-a-related-post/

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

This topic contains 7 réponses, has 2 voix.

Last updated by marcusC-4 Il y a 3 années et 3 mois.

Assigned support staff: Minesh.

Auteur
Publications
#1094590

I am setting up a website that uses WooCommerce for sales and will allow vendors to sell on their site as well. Vendors have been setup as a custom post type and will also have sub-vendors. The sub-vendors have been setup as a custom post type and will sell under the Vendor’s brand name but receive their own piece of the commission.

Here is the Commission Structure
There are 2 steps to figure out how much commission is owed to everyone.

First, there is a commission to the Vendor, which will be a percentage or flat-rate depending on the product. It’s important that this rate can be set on the product editing screen.

Second, after that has been calculated, the Vendor has to pay any sub-vendors who are associated with that product. The sub-vendor percentage or flat-rate also needs to be input on the Product editing screen.

Here is a real-world example
Someone buys a book for $100. On the product page, a commission rate of 80% was set for the Vendor. It was also associated with a sub-vendor & a commission rate of 10% was set.
The revenue will be divided like this:
The website receives 20% of the total sale amount (in this example, $20)
The Vendor receives 80% of the total sale amount but then has to pay the sub-vendor 10% of the Vendor's commission (in this example, the Vendor gets $72 when all is said & done)
The sub-vendor receives 10% of the Vendor's commission (in this example, the sub-vendor makes $8)

All of these commission values can exist outside of WooCommerce. This is just for reporting purposes.

My question is this:

What is the best way to connect the Vendor and sub-vendor the WooCommerce Product? Should I make the Product a parent to the Vendor post type? If so, I know that will allow me to select the Vendor on the product editing page, but will it also allow me to select a sub-vendor, which would be grandchild post type?

#1094697

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Hello. Thank you for contacting the Toolset support.

Well - I would like to know here where you will setup the commission %80 and 10%? When you setup vendor and sub-vendor? - or it will be setup as separate custom field inside the vendor?

What I am thinking is to have a one to many relationship setup between Vendor (parent) and Product (child). And then with vendor post type - add the post reference field to connect vendor child to it.

Please check following:
https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/using-post-reference-fields-to-display-information-from-a-related-post/

So - the Vendor has sub-vendor setup as post reference field as a result vendor and sub-vendors are connected and vendor is connected to product. Makes sense?

#1094841

Minesh,

Using the post reference field seems like a great solution. Would that allow me to select more than one sub-vendor? Sometimes we have multiple sub-vendors connected to a product.

You asked where I would enter the commission rate and that is a very important part of this. I need to be able to set that rate on the product edit page so that I can change it for each product. We have to be able to set a flat rate or percentage commission for each connected Vendor and sub-vendor on that product editing page.

Ideally, I would set a "global" commission rate on Vendor page when setting them up and do the same on the sub-vendor page when setting them up and always have the ability to override that global value by inputing something different on the product editing page.

Is something like that possible using a custom field?

#1094856

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Using the post reference field seems like a great solution. Would that allow me to select more than one sub-vendor? Sometimes we have multiple sub-vendors connected to a product.
=> No - post reference field is meant to have only one selection.

See this section and read it carefully - what happens when you want multiple instance of post reference field:
=> https://toolset.com/documentation/post-relationships/how-to-display-related-posts-with-toolset/using-post-reference-fields-to-display-information-from-a-related-post/#repeating-post-reference-fields

You asked where I would enter the commission rate and that is a very important part of this. I need to be able to set that rate on the product edit page so that I can change it for each product. We have to be able to set a flat rate or percentage commission for each connected Vendor and sub-vendor on that product editing page.

Ideally, I would set a "global" commission rate on Vendor page when setting them up and do the same on the sub-vendor page when setting them up and always have the ability to override that global value by inputing something different on the product editing page.
=> Ok - thats both options you mention are possible either setup on product edit page or on vendor and sub-vendor page.

Is something like that possible using a custom field?
==> Yes - exactly. You need to add custom field that will hold the commission value.

#1094860

Got it. Thank you!

I think (hope) I can take it from here. 🙂

Marcus

#1095087

Hey Minesh,

I have been able to setup the post types & have a custom field for Commissions, but I have 1 issue.

When I set the commission rate on the product editing page, it overrides the global value everywhere. What I need is to be able to set a custom commission rate on each product. For example, one person could sell 2 products and have 2 different commission rates.

Currently, if I change the commission rate in one place, it changes it everywhere.

#1095633

Minesh
Supporter

Languages: Anglais (English )

Timezone: Asia/Kolkata (GMT+05:30)

Well - could you please resolve this ticker and we will continue with your new question with the following new ticket:
=> https://toolset.com/forums/topic/split-best-approach-for-woocommerce-product-child-grandchild-post-types-set-commission-rate/

#1095646

Done -- I replied on the other ticket.

Thanks,

Marcus