In my site there is one custom post type obituaries.
Using woocommerce product facility I want to create flower shop.
So I want to create relationship between obituaries and flower shop. So If customer place order for flower that flower should be linked with that obituary.
Can you please help me for creating relationship between obituary and flower. I have created relationship(One to Many) but it is not working.
We have a current unresolved issue where using WC Orders in post relationships is not working. It is with the developers and I expect it to be resolved soon, but if you try to set up such a relationship at the moment you will likely encounter problems (JS errors on the post edit screen when making the connection).
You say that you have created a one-to-many relationship between Obituaries and flowers but it is not working.
What does "not working" mean? What are you expecting to happen, and when?
It sounds like you are connecting the product (flowers) rather than the orders to obituaries, is that right?
If you edit an obituary and at the bottom of the edit screen add a related flower product, does that work? That is, does the relationship itself work?
It sounds like you are expecting something to happen during the order process, could you describe what?
And once you have established a connection between the posts, how do you intend to use it (that might affect how you want to set this up in the first place)?
Obituary is the custom post type which i have created using toolset plugin.
To Display flowers under obituary i have created a view.
Now I am explaining what i wanted to do.
Where user click on Obituary under flower tab it will display all the flowers over there. Where user click on Add to Cart button I want to link flower with Obituary. So vendor can able to see which flower is linked with which obituary. User can send more than one flower to one obituary.
I need some more details about how exactly you would expect this to work to give specific advice about how to implement it.
I understand that the final objective is that it should be possible to visit an obituary post and on that post see the flower products that have been bought in relation to that obituary.
The question is how and where you expect a person buying flowers to indicate which obituary they are for.
Is the user browsing a WooCommerce shop and adding flowers to the cart, then completing the WooCommerce workflow to place the order and pay for it online? Where in this process is the obituary specified, because the actual connection between flower product and obituary would be made when the order is completed, and the challenge is knowing what obituary the flowers belong to at that point.
The question is how and where you expect a person buying flowers to indicate which obituary they are for.
---Answer for above question is when user click on Obituary Detail. I have created one tab for flower shop in which I am displaying all the products using View and Post Form.
Is the user browsing a WooCommerce shop and adding flowers to the cart, then completing the WooCommerce workflow to place the order and pay for it online?
Yes user will add flower in cart and will pay online using paypal or credit card.
Where in this process is the obituary specified, because the actual connection between flower product and obituary would be made when the order is completed, and the challenge is knowing what obituary the flowers belong to at that point.
-------- I don't know answer of the above question and I seeking help regarding that.
----------It would be great if you can help me for this because I am stuck here and can't able to get any soultion
OK, thanks for clarifying, you are not using the WC shop page, but starting from the Obituary post, where you display flowers with Add-to-cart buttons.
Unfortunately, I cannot see any way to bridge the gap between the origin Obituary post and the checkout page so that the checkout page is aware of the origin Obituary post as you proceed via the cart. There may be a way to pass a variable along—as a URL parameter, for example—but you would need a WooCommerce expert to know if that were feasible.
In terms of achieving this with Toolset, you would need to effectively fake adding products to the cart and use the Toolset Forms Commerce workflow to publish some post and be charged for it.
The simplest version would be with a single form, where above the form you display a grid of flower products. Then the form itself includes a field where the user chooses the flowers they want to buy.
This field is then used to set which product is purchased when submitting the form.
If you create a many-to-many relationship between obituaries and products, the post which is published could be of an intermediate post type, for example, and you would use the API—possibly one of the Forms Commerce hooks such as cred_commerce_form_action—to run a snippet of code that used toolset_connect_posts to connect the Obituary and the product.
If such a workflow seems feasible then try setting it up and see how far you get. I expect you would need help with using the APIs to connect the product and obituary, but let me know how far you get.