Skip Navigation

[Resolved] Quote process with types, relationship and CRED

This support ticket is created 5 years, 7 months ago. 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.

Sun Mon Tue Wed Thu Fri Sat
- 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 10:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Kolkata (GMT+05:30)

This topic contains 16 replies, has 2 voices.

Last updated by domenicoS 5 years, 6 months ago.

Assisted by: Minesh.

Author
Posts
#1115157

Hi,

I’ve a complicate issue I’m working on, but I need your great support.
The aim is to have a request quote function using types, relationship and cred.
I try to explain the situation
1) I’ve a custom post Accommodation where user can see an accommodation with all details. In every accommodation page there is a form “Accommodation Availability Form”. The user can fill in the form to request a quote to the Accommodation manager (which is the author of the accommodation page). When a user sent a request, a notification arrive to the author.
2) On the notification that the author received by email there are all the request details (number of person, of children, dates, ecc). There is also button that links a page contained a form “New Offer” related (by relationship one-to-one) to the custom post Offers. Then the author after receiving the email and clicking on the button go to the page with the form to add a new offer for the user who request it. The new offer is saved as “Quote” custom post type.
3)The “New Offer” form contains just few fields.
- Choose the product to sell
- Set the price
- Submit
When the author fill in the form, he can choose a product to sell (that is a room) and, by the other field of the form, he can also sets the price of this product. Clicking on the submit button “Send Offer” an email is sent to the user (who sent the first request).
4) In this email is displayed a message with offer details and the button “add to cart”. The user can buy the product by WooCommerce adding the product offer by the property manager to the cart.

Point 1 and 2 are ok! My question and issue is on the point 3 and 4, because maybe some coding is needed.:
- A) how is possible to make the quote of the property manager an answer to the user. In few words is needed to catch the email of user sent the request. Then clicking on the button “send quote” should be a double action: save the data of the quote and send an email to the user. (catching his email)
- B) When the property manager fill in the quote, this data are needed to create a temporary price of the product choose. Then in the notification arriving to user, should be displayed a button linked to add to cart action. Should be created a “floating link” associated to the button which allow to catch the data of “Quote” custom post type using this data to add the price to the cart.
Can you help me?

#1115697

Minesh
Supporter

Languages: English (English )

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

Hello. Thank you for contacting the Toolset support.

1) I’ve a custom post Accommodation where user can see an accommodation with all details. In every accommodation page there is a form “Accommodation Availability Form”. The user can fill in the form to request a quote to the Accommodation manager (which is the author of the accommodation page). When a user sent a request, a notification arrive to the author.
=> Ok, this can be done with Toolset Forms and using Email notifications.

2) On the notification that the author received by email there are all the request details (number of person, of children, dates, ecc). There is also button that links a page contained a form “New Offer” related (by relationship one-to-one) to the custom post Offers. Then the author after receiving the email and clicking on the button go to the page with the form to add a new offer for the user who request it. The new offer is saved as “Quote” custom post type.
==> OK

3)The “New Offer” form contains just few fields.
- Choose the product to sell
- Set the price
- Submit
When the author fill in the form, he can choose a product to sell (that is a room) and, by the other field of the form, he can also sets the price of this product. Clicking on the submit button “Send Offer” an email is sent to the user (who sent the first request).
==> How the product is configured? Is it as a new post type "rooms"?

4) In this email is displayed a message with offer details and the button “add to cart”. The user can buy the product by WooCommerce adding the product offer by the property manager to the cart.

Point 1 and 2 are ok! My question and issue is on the point 3 and 4, because maybe some coding is needed.:
- A) how is possible to make the quote of the property manager an answer to the user. In few words is needed to catch the email of user sent the request. Then clicking on the button “send quote” should be a double action: save the data of the quote and send an email to the user. (catching his email)
===> Toolset Forms offers hooks and email notifications. Well - I need to understand the flow and how you configured your setup.

- B) When the property manager fill in the quote, this data are needed to create a temporary price of the product choose. Then in the notification arriving to user, should be displayed a button linked to add to cart action. Should be created a “floating link” associated to the button which allow to catch the data of “Quote” custom post type using this data to add the price to the cart.
==> There is no way to add "Add to Cart" button to email until you follow the custom programming approach. This is something out of the scope of Toolset.

Can you help me?
==> Sure.

What I would suggest is divide your project in the small modules and study and check the feasibility of features which you can implement with Toolset and which needs custom programming.

I would suggest you to take step by step approach.

we have detailed tutorial available on how you can build membership sites using Toolset plugins:
=> https://toolset.com/learn/create-membership-site-wordpress-using-toolset-plugins/

I suggest you should go through above Docs carefully and check what you can accomplish with Toolset and find alternatives which is not covered within above Docs:

Also, you can use our test platform http://www.discover-wp.com where you can create the free test site for you to test Toolset plugins features:
=> https://toolset.com/faq/how-and-why-to-create-a-test-site-in-discover-wp/

We also have travel destination site:
=> https://discover-wp.com/site-types/travel-destinations/

Also, we have readymade site available namely "Classifieds" site that may help you as well:
=> hidden link

Even you can download and install all available reference site to your local test site using Framework Installer plugin.
=> https://toolset.com/account/downloads/#application-frameworks
[At bottom of the page - you can download it]

#1115798

Hi Minesh, thanks for your attenction

Sure, I go step-by-step.
Step 1) and step 2) are already correctly set.

We can set these steps:
3) reach the user email to send him an answer with the quote
4) Display in the notification with the quote a button which bring user to the cart
5) Set the cart with the product (room) chosen by the author for the user with the relative price

So we can see the step 3 – “reach the user email to send him an answer with the quote”:
I've already the "New offer form".

With this form the property manager can choose the product (a simple WooCommerce product associated to him) and he can also set the price. When the author clicks on “send offer” button an email should be arrive to the user who sent the first request. Of, course is possible to do this with a notification.
The problem in this step is: How is possible to reach the user email? maybe this email is stored somewhere and we have to reach it.
Remember that when the user sends the first request the author receive an email with a link. Clicking on the link the author goes out from the form so we "lose" the connection between the user and the form.

#1116450

Minesh
Supporter

Languages: English (English )

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

We can set these steps:
3) reach the user email to send him an answer with the quote
4) Display in the notification with the quote a button which bring user to the cart
5) Set the cart with the product (room) chosen by the author for the user with the relative price

So we can see the step 3 – “reach the user email to send him an answer with the quote”:
I've already the "New offer form".

With this form the property manager can choose the product (a simple WooCommerce product associated to him) and he can also set the price. When the author clicks on “send offer” button an email should be arrive to the user who sent the first request. Of, course is possible to do this with a notification.

The problem in this step is: How is possible to reach the user email? maybe this email is stored somewhere and we have to reach it.
Remember that when the user sends the first request the author receive an email with a link. Clicking on the link the author goes out from the form so we "lose" the connection between the user and the form.
==> Well - what you are saying is still not clear to me, even I shared your reply with another colleague even he do not get idea. Whetever you are saying is either complex or needs custom programming as far as I can see.

I can better guide you in the right direction if you can share problem URL and step by step info to follow so that I can understand your site flow and tell you if its possible and within range of Toolset support or not. I just understand you want to reach some email but which email from where? within Toolset from?

#1116594

Ok, sorry it is clear in my mind but is not so easy to explain. For this reason I share with you all the process, because a single step is complex to understand.

I try with pratical example.

I'm reffering to a website which is a marketplace, whir list of accommodation. When a user go on the webside can choose an accommodation and send a resuest of avaibility. The accommodation manager receive thi email (which is the notification of a form).

This is the page of the accommodation: hidden link

At the end of the page you can see the form whcih the user can use to send a requst to the accommodation. (the name of this form is Accommodation Availability Form)

As I said when the user send this request, a notification rrived to Accommodation manager.

In this notification there is this:

"Dear Accommodation manager,
You've received a new request from a customer.
Please send your quote to the customer clicking on the link below:

hidden link

Thank you"

Then when the Accommodation manager click on the link a new page will be open. In this page there is another form and it is possible to send to the user the quote. (the name of this form is Seleziona new-offer). So the Accommodation manager fill the form. When he submit it a notification arrived to user.

The problem is how can I reach the email of the user.

Infact when the user sent the first request (using the form Accommodation Availability Form) put his email which is stored somewhere.

When the accommodation have to answuer uses the other form ( new-offer). This is not connected with the first form so is not easy to reach the email of th first form.

I think should b more clear now.

Please let me know, thank you

#1117105

Minesh
Supporter

Languages: English (English )

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

OK - so, the only way I see is when you send url in the email, you should add email as url param:

Something, as given under:

<em><u>hidden link</u></em>

So, when user click on the offer and redirected to above offer page, the user email will be available as url param so you can access it and yes, you also need to find a way how you should save the user email field.

This is the only way I can think of and within this solution, I don't see it's logically related to Toolset but its logical thing how you can setup your flow.

#1118583

Hi Minesh, I found a possible solution. This should be the process-

1) a user arrive to the accommodation page and send a availability request filling in the CRED. This from will create a new post type "Quote".

2) a notification arrive to the accommodation manger. In this notification there is the edit link to the post type "quote" created by the user.

3) the accommodation manager edit the post with an editing form with 2 fields: the price and a select field where he can choose which product will sell to the user.

4) When the accommodation manager finish to edit the post type quote, it will be updated with information set by the accommodation manager and a notification arrive to the user

Untill this step everything is already done. I need help with the next steps

5) when the user receive the notifcation after the accommodation manager editing and he shoud be able to buy the product offers by the accommodation manager at the price set with the previous form.
How can we do this? Maybe some custom code is needed!
Can you help me Minesh?

#1118957

Minesh
Supporter

Languages: English (English )

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

5) when the user receive the notifcation after the accommodation manager editing and he shoud be able to buy the product offers by the accommodation manager at the price set with the previous form.
How can we do this? Maybe some custom code is needed!
==> Well - did you check Toolet Forms commerce?

Please check the following:
https://toolset.com/documentation/user-guides/using-cred-commerce-to-add-payments-to-forms/#2-connecting-products-to-forms

Once you activate Toolset Forms Commerce - it will allow you to either select product or you can select custom field that holds product ID. Please check if this help you to acheive what you need otherwise its pure custom programming case which is eventually beyond the scope of our support policy. We would like to help our customers but we also need to make sure we provide support within our support policy.
=> https://toolset.com/toolset-support-policy/

If you need custom programming for your project - please feel free to contact our certified partners:
=> https://toolset.com/contractors/

#1119662

Hi Minesh,

Thank you, maybe the oolet Forms commerce should be the solution, but I still your support to set it.

Can you please mark my next answer as private so I can share with you the links?

It helps you to support me.

Thank you

#1119666

Minesh
Supporter

Languages: English (English )

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

Here all required information listed how you need to setup the form:
=> https://toolset.com/documentation/user-guides/using-cred-commerce-to-add-payments-to-forms/#2-connecting-products-to-forms

I have set the next reply to private which means only you and I have access to it.

#1120667

Minesh
Supporter

Languages: English (English )

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

Sorry - its too much information for me. So lets go step by step.

Could you please tell me from where I can catch the product that is seen/fetch the room selected by the accommodation manager? Once I can see from where to fetch the product ID I will have the clear picture.

I have set the next reply to private which means only you and I have access to it.

#1120728

Minesh
Supporter

Languages: English (English )

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

Well - I dont know why you added following code:

add_filter('cred_commerce_add_product_to_cart', function($product_id, $form_id, $post_id){
    if($form_id == 24662){
	//	session_start();
        if(isset($_POST['product_id'])){
			$product_id = $_POST['product_id'];
			$_SESSION['target_post_id']   = $post_id;
        }
    }
    return $product_id;
}, 20, 3);

But I've adjusted the code for form ID 25474 that is form "Booking Room Form" as you can see as given under:

// Change the Room product ID
add_filter('cred_commerce_add_product_to_cart', function($product_id, $form_id, $post_id){
    if($form_id == 25474){
		
        if(isset($_POST['product_id'])){
			$product_id = $_POST['product_id'];
			$_SESSION['target_post_id']   = $post_id;
        }
    }
    return $product_id;
}, 20, 3);

Now, once you click on "Book Now" button on the following page:
=> hidden link

I can see the correct selected product "Test Room" is added to cart.

Could you please confirm.

#1120769

Yes, Minesh, it work perfectly. I try also to change the product in quote and everything is ok.
Now next step is to get price not from the product but from the quote. The field is "wpcf-quote-person-price" (now is set on 256).

I tried with this code, but doen not take the value

add_action('woocommerce_before_calculate_totals', function(){
	session_start();
	if($form_id != 25474 && !isset($_SESSION['target_post_id']))return;
	global $woocommerce;
	
	$post_id = $_SESSION['target_post_id']; 
	$price = 0;
	foreach ( $woocommerce->cart->get_cart() as $key => $cart_item ) {
		
		$product_id = $cart_item['data']->get_id();
		$person_total_price = get_post_meta($product_id, 'wpcf-quote-person-price', true);



		$cart_item['data']->set_price($person_total_price); 
	}
	
}, 999);
#1120815

Minesh
Supporter

Languages: English (English )

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

Well - I gave a try but unfortunately, I'm fail to set the custom price. I already tried to help you where Toolset is applicable but now this is beyond the scope of our support policy where Toolset is not applied but now this is pure custom code and belongs to WooCommerce.

Could you please consult WooCommrece experts on this and try to resolve your issue.

#1121313

I Minesh, I'm sorry but I think is not as you say. This is linked to a toolset process, I'm not asking to customize woocommerce or website, but the final step of a toolset process as I said.
So, no problem. I'll try a different solution.
Thank you

This ticket is now closed. If you're a WPML client and need related help, please open a new support ticket.