[Resolved] Pass custom fields from a custom post to woocommerce product

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.

Related documentation:

This topic contains 16 replies, has 3 voices, and was last updated by  davidZ-4 5 months, 2 weeks ago. The support staff assigned to this topic is Nigel.

Viewing 15 posts - 1 through 15 (of 17 total)
Author
Posts
#526043

I am trying to: pass custom field content that was created by a CRED woocommerce to a product order form.
in other words the process is
1. User fill a custom post CRED form and submit it (free /fee) . the custom post is created and published
2. any user view the custom post on the front end
3. any user click to purchase a product related to the custom post he view (have a few products options for the custom post
4. user redirected to a product page
5. product page include custom fields from the custom post e.g. title, name, date, etc..
6. user select variations and quantities
7. user complete checkout
8. user and store manager receive email with order information including custom fields from the custom post
9. store manager can custom the product based on the order information including custom fields from the custom post

I visited this URL: hidden link

I expected to see: product page include custom fields from the custom post e.g. title, name, date, etc..

Instead, I got: nothing as I'm not sure how to do this with toolset. I looked at the post https://wp-types.com/forums/topic/fields-from-existing-custom-type-of-posts-into-woocommerce but its missing some steps to complete what i'm looking for.

I thought of parent child relationship where the custom post is a parent and product is a child but i'm not sure if this is the right way to go.

also, passing query string from the is an option but i'm not sure how to pass them into the product page and than to the order info in the email.

Please advise,
thanks,

David

#526315

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi David,

Thank you for contacting our support forum.

I'm not quite sure I understand the issue fully, Is it that you want to display your custom fields on the product page itself?

Or is it that you want these custom fields that were filled out by the customer to be stored on the product and then displayed on the frontend.

Please let me know.

Thanks,
Shane

#526392

Hi Shane,

the first option is what i'm looking for. I want to display custom fields on the product page itself.
I already use the second option to creat the custom post.
think about as one client submit the custom field for free
the second client or any client can view the custom post and order a product with data stored in the custom fields from the custom post.

hope this makes it clear.
thanks,

David

#527122

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi David,

Thanks for the information.

You can actually do this by taking a look at the link below.
https://wp-types.com/learn/create-an-ecommerce-wordpress-site/single-product/

Thanks,
Shane

#528105

hI Shane,
yes, I have looked at this link before.
however I dont understand how to take the information from a custom post and plug it into the product page and transfer it to the order.
I can see that I can plugin the custom field in the product page.
so I created custom field that apply to both custom post and products.

again the process is:
client submit a custom post that have custom fields in it (paid or not is not the issue here, I know how to do both)
Second step is client or owner of the custom post want to purchase a product that have information (custom field) from the custom post.
client click on buy product from the custom post from end and redirect to checkout page that include the custom fields from the custom post and complete the order.

so my question is how to take custom fields from custom post into a product.

I hope its more clear.
please advise,
thanks,

David

#528196

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi David,

I believe I understand a bit more clearly now.

But i'm still not clear on a few things.

The user is creating a Custom Post or a Product, or Both

Please let me know.

Thanks,
Shane

#528221

Hi Shane,
allow me to be more specific.

user go to hidden link and create a custom post with custom field in it as seen on the page.
after submitting the post (for a fee or for free) the post is been published. see example of published custom posts at hidden link
a specific custom post look like this post hidden link

I want to add a button to the custom post page (example page hidden link) that will allow a user to purchase of a product that will take the name, URL and Years from the custom post and create a customized product.

For example buy a picture print with a picture from the custom post, including the full name, the birth and death years, and the URL of the custom post.

the user is redirected to the product page and the information to create the customized product is populated automatically from the custom post information.

many users can order multiple product for the same custom post.
at the moment I'm looking at 3 different products per custom post: Picture print, Labels, and a plate with the information from the custom post.

I can create the three products in woocommerce but not sure how to customize the order process so the required fields from the custom post will come from the custom post.
I dont want the user to manually input the information as errors will happen and the UX will be very bad.

please let me know if you have any question.
thanks,

David

#528438

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi David,

Ok so based on this workflow i fully understand what you want to achieve. Its pretty much creating a custom product based on What the user selects.

Ok Regarding the custom product section I wouldn't be able to assist with this since it would be going into woocommerce code to achieve. It will also take some custom coding to achieve as well where the button is created on the page to run a code that will create the custom product once it is clicked and allow the customer to order that product.

Even though i'm not able to assist with the coding of this I can however point you in the right direction where you can get some assistance from our certified consultants.

You can contact them by going to the link below.
http://wp-types.com/consultant/

Please let me know if this helps.

Thanks,
Shane

#528648

Hi Shane,

I'm sorry to here that. it sounds like toolset cannot do what I want.

as for creating the custom product, it seems that toolset know how to do that and the link you provided show how to do just that. so I can create a custom product with toolset without going to woocommerce code as you suggested.

the only thing that is not clear to me is how to pass the fields from the custom post to the custom product.

when I insert a custom field (that is available for custom post and products) into the product template I can theoretically use a parent child relationship but I'm note sure about the definitions.

for example can I create product as child of custom post and than insert the data to the product from the parent custom post?

or should custom post should be child of product and when linking to the product I can pull the child data into it.

also, i'm not clear if I can use the "The parent of the current post (WordPress parent) " relationship for this.
or use query strings to do this task.

Please note that sending me to vendors that will do this for me is defeating the purpose of using toolset.

Its not the first time I hear the easy way is to hire a vendor to do it but with some research I was able to find solutions for all my issues without hiring a vendor.

I ask you to please help me by escalating this to a product manager or the developer lead that manage this features at onthego systems. I'm sure they will be able to provide a solution with some example I can tweak like I've done many times in the past.

Thanks,

David

#528874

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi David,

Before I can escalate this ticket I will need to cover all the grounds .

From your explanation I gather that this is you workflow:

- Customer creates a Post using CRED
- That Post creation then Creates a product with the custom fields filled out from the previous post, essentially a custom product based on that Post.
- The user is then redirected to that created custom product.
- The customer then selects the quantity of that product and then they can order that product.

My question is why not just create a custom product from the beginning instead of this 2 step process. You can add the custom fields that you want the user the product to have and then allow the user to create the custom product.

Then with CRED the user can be redirected to that newly created product and you can use our Views alongside Woocommerce views to display that products custom fields that the user filled out. The user can then select the quantities that they want and order.

Now that is the simplest way I can think of it and it would still require some custom coding so that the custom fields that are in the product be included in the order email.

If we go by your route we can create the Custom Post, but then there is no way to create a product after that except through use of code and then copying those attributes that were filled out to that created product.

We should be able to achieve this by using our CRED hooks to create the product and redirect us to that product.

Take a look here as to an example of what needs to be done to create the product through code.
hidden link

Please let me know if this clears things up a bit for you.

Thanks,
Shane

#529569

Hi Shane,
I understand that you need to cover all the ground and that's is fine however this is taking very long and it seems that for some reason I didn't explain the issue clearly enough.

so I will try again. so here we go again:

"- Customer creates a Post using CRED" - yes, you got that right

"- That Post creation then Creates a product with the custom fields filled out from the previous post, essentially a custom product based on that Post." - it is not clear to me what you mean here.
what happen after the post was created that the post is published end of the first portion.
now, at any time the post creator or any other person can come to the post that was created and buy a product that is related to the post. this can happen a minute after the post was created or a year after the post was created.

"- The user is then redirected to that created custom product." - user click on purchase button located on the post page to buy a product related to the post. (related mean: have data from the custom post printed on the product).

"- The customer then selects the quantity of that product and then they can order that product." - yes you got this right.

As for your question "why not just create a custom product from the beginning instead of this 2 step process" here is my answer:
1. the user that create the custom post is creating a memorial page. he already plugin the information for others who might not know the information in the first place. lets say a grandchild who wants to have is grandfather picture with a link to the memorial page
2. having each user create the custom post multiple time is not beneficial and is a redundant step., instead the user that created the custom post (memorial Page) already have the information posted correctly so asking for each person to plugin the information again manually, like name, link to the custom post, and years is not a good user experience.

I need away to get custom post fields that been published using creed into a woocommerce custom product. I know how to call the custom fields using query string and wp-types but I dont know how to put it in the custom product fields.

for some reason I dont see another message I submitted in this thread. so here it is again
I can pass the custom fields from the custom post using query string as follow: hidden link
than in the product template layout I have the code

[types field='first-name' id='[wpv-search-term param="post"]'][/types]

in this way I can pull any information from the custom post to the custom product page.

now the million dollar question is how to take these fields and plug them in the custom product information when the order is submitted.

I hope my question is clear now.
Thanks,

David

#529805

Shane
Forum moderator

Supporter languages: English (English )

Supporter Timezone: America/Jamaica (GMT-05:00)

Hi David,

I understand more clearly .

So we have a few issue here and i'll separate down into points.

1. That Post creation then Creates a product with the custom fields filled out from the previous post, essentially a custom product based on that Post

A. Explaining this a bit more is whenever a user creates a post, a product is automatically created at the same time based on that products fields. This portion will be well within our forum scope to assist you with. I'm guess this is not the desired operation.

2. If it's at the user's discretion when the product then we can create the product through a button click, does the user get an option to create the type of product ? example flyer, photograph etc.

Please let me know,

Also could you provide me with admin access so I can setup an example for you.

Thanks,
Shane

#530983

Nigel
Forum moderator

Supporter languages: English (English ) Spanish (Español )

Supporter Timezone: Europe/London (GMT+00:00)

Hi David

Shane is on vacation and I'm going to take over this ticket.

It's quite a long thread so it will take me a little while to go through it all and make sure I don't ask you to repeat yourself, and I realise it has been ongoing for well over a week already, so I'll get to it as soon as I can.

I have several quite involved tickets in my queue right now, but I'll update you as quickly as possible.

#531511

Nigel
Forum moderator

Supporter languages: English (English ) Spanish (Español )

Supporter Timezone: Europe/London (GMT+00:00)

Hi David

I read through the previous posts and I have a pretty good handle on what you are aiming to do.

Here's where I see part of the problem.

I understand that you have some kind of memorial post, and you want users to be able to buy products related to that memorial, so, for example, a photo print is the product and the image comes from the memorial post.

The problem is that adding custom fields to a product (to pass on details from the originating memorial post) won't work because the custom fields on a product would be the same for all users. You can't have a set of custom fields on a product for one user, and another set of custom fields for another user. (OK, you could add the custom fields at the start of the process and then remove them after successful checkout, but only one person could ever use your site at a time.) Likewise it doesn't make much sense to have a parent-child relationship for products because it would be the same for all users.

Orders are unique for users, so you could look at passing url parameters to the product page (the product itself isn't affected, the url parameters are just there) and then when the order is placed these url parameters are used to update custom fields on the order.

The first part would involve adding the parameters to the product links on the memorial page. The second part would involve adding custom PHP to update the order with the fields coming from the url parameters. The Toolset API can't really help you there, you would be looking at using the WooCommerce API to find the required hooks to trigger your code, and you will need to review the WooCommerce documentation for what's available there.

I haven't used them and am not familiar with their inner workings to know how you might integrate them with Toolset, but it seems like you could make this easier with WooCommerce extensions for product customisation (e.g where the product was a necklace and clients could add a message for engraving).

Try looking at https://woocommerce.com/products/product-add-ons/ or hidden link and see if they might help fill the gap between what you can do with Toolset and what you can do with WooCommerce.

#533110

Hi Nigel,
thanks for the follow up.

so if I will sum it up toolset cannot create fields like 'woocommerce product add-ons' (actual woocommerce plugin) and allow users to populate the data to customize the product like engraving or text print on a product. hence my scenario cannot be build using toolset.

that's disappointing.

I have found one potential solution that might help and I'm investigating this route but it means purchasing another plugin...

please let me know if I'm right with my understanding or if a solution using toolset is possible.
Thanks,

David

Viewing 15 posts - 1 through 15 (of 17 total)