[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.
This support ticket is created Il y a 6 années et 3 mois. There's a good chance that you are reading advice that it now obsolete.
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.
Aucun de nos assistants n'est disponible aujourd'hui sur le forum Jeu d'outils. Veuillez créer un ticket, et nous nous le traiterons dès notre prochaine connexion. Merci de votre compréhension.
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?
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.
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?
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?
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.
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.
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.
Les nouveaux fils créés par Minesh et associés à celui-ci sont repris ci-dessous :