Drupal 7: Generating HTML e-mail depending on chosen term and node - drupal

I want to make ability for anonymous users to get e-mail with discount coupon for manually chosen product.
It could be put in one form (select lists) or multiple steps (product selection > user info)
How it should work:
User in page/block chooses taxonomy term (category of product)
User chooses node (filtered by chosen taxonomy term)
User inputs name, e-mail.
User clicks submit button
Html e-mail is being generated and sent with user name, chosen node title and custom field from that node with discount rate.
Is it difficult to achieve it work?
Thank you for your help.

What you're looking for can be recreated with the Webform module (https://drupal.org/project/webform), Simply create a webform with your desired fields (category, node, name, email) and then customize the receipt to use the [node:discount-code] token for the user's chosen node.

Related

Is it possible to pass a special query parameter value to a WooCommerce product link?

I am looking to use WooCommerce in a bit of a strange way, and I'm wondering if there is any way to make this possible. Here's my desired workflow:
Step #1: From a different site subdomain, provide a link to a certain virtual product, but with a query parameter with a unique user id number.
Explanation: The user is at othersite.example.com, and they get a link to buy a product in a WooCommerce store set up with a wordpress site at https://example.com/product/virtual-product
However, this product will be a payment to unlock something on the othersite.example.com site which has its own user and authentication system. (Firebase)
Would it be possible to pass a user id from the othersite.example.com by way of a url query parameter and then have that included in the order info?
ie. From the othersite.example.com someone could be given a link to the product like this https://example.com/product/virtual-product?userid=00000000000000000, with 00000000000000000 being their user id at othersite.example.com.
Then if that userid query value could be included in the order, the following steps should be doable.
Step #2: Have a webhook that fires when the product is purchased, telling a server managing the users for othersite.example.com that the user with userid 00000000000000000 has made a successful purchase of that product.
Is there a way to accept custom values like this to the order? Or is this totally out of the scope of WooCommerce's functionality?
Thanks so much.
I believe that it can be done by using a redirection/link directly to the checkout page, like: "http://yourdomain.com/checkout/?add-to-cart=PRODUCTID&000000" (tested)
In the example, "checkout" stands for the name of your checkout page, "PRODUCTID" stands for the id of desired product, "000000" stands for the user id of redirected person in the other website.
Then you can add a hidden input field to the checkout page (into checkout form, so you will see this value in order) and using the URL you can assign the "000000" (user id) to the value of this field.
I hope that works. If you have any problems with implementation, you can ask me.
- Useful link for hidden input field addition: https://stackoverflow.com/a/42614905/11003615
- Useful link for getting value from current URL using JS: https://web-design-weekly.com/snippets/get-url-with-javascript/
- Useful link for getting value from current URL using PHP/Wordpress Core: https://wordpress.stackexchange.com/questions/274569/how-to-get-url-of-current-page-displayed
- Useful link (contains 4 parts) for adding a custom field to checkout & validating this field & saving this field to order fields & displaying the value of this field in order page: https://docs.woocommerce.com/document/tutorial-customising-checkout-fields-using-actions-and-filters/#section-7

I want to fetch submitted gravityform entries into another gravityform (wordpress)

Suppose I made form A and form B, I get a unique ID after submitting form A after that, another person opened form B and he entered just a unique ID given by me and enter additional information and submit it, then he might see the name and email ID that I entered in form A.
Please guide me to do this, also tell me if there is any form plugin or gravityform addon for this.
Now, in this case, I am trying to fetch submitted entries from form A to form B by using a unique ID that I created. (for unique ID I have a plugin so no worries about it)

Gravityform registration add-on update user feed

I'm using gravity form registration add-on to create users with a specific role X, I used a (create user) feed for this and assigned it to this role. Now I need the current user with role X to Update his role to Z, I going to create a form with (update user feed). The issue I face is, I don't want the user to be updated automatically, I need the same manual activation function exist in (create user feed)
so the sequence going to be after the user X submit the form I going to show him a confirmation message telling him to wait until we validate his request

Showing Users based on current users Data in drupal 7

I have created an extra field Date of Birth in the user fields.
Now how can I show all the users with the same birth date having the logged in users birth date.
You'll want to create a view of users with a contextual filter for the birthday field. Set the filter to provide a default value in php code. Then in the filter's PHP box, use the global $user object to fetch and return the current user's birthday. Then to exclude the current user from the results, add a filter for user:current, and click the "no" option.

How to display and hide Drupal 7 fields, based on value of a specific field

What I am trying to do here is controlling how a group of fields are showing up on node view. I don't want to control them by user role, as this is going to be a node level permission and I don't want these permissions affect other nodes with the same content type.
For example imagine I have three different roles: ROLEA, ROLEB and ROLEC. Each role has it's own permissions set for accessing to fields. When a node is created for the first time, a user with role of ROLEA, can see couple of fields and can edit the value of those fields. When node is published, a rule/action get called through Rules module, and will set a status field in that node to STAGE1. After this event (a new node created), if user (ROLEA) goes to that node that was just created by herself, those fields that were editable before, should be read-only now. This means when Rules module, set the value of the status field to STAGE1, when that node wants to get loaded by Drupal, we need to check the status value, and based on that if it was for example STAGE1, modify some other field in that particular node, read only or editable, or in some cases hide them from user. So my guess is to create a module that every time a node of that type, is loading, check the status field (which is a field that we have created in that node type) and based on the value of that field, decide which node should show up or hide. This should override the permission that have been set for those fields on that particular node type.
What I am trying to do is creating a method to control which field is going to be read only /editable / hidden based on the value of a specific field in that content type, which has been set by Roules module, based on different stages of working on that node by different group of users. I am not using Organic Group. I use Drupal 7 and Rules module and couple of other permission related modules. But I found that there is no such a way to handle field visibility in node level, separate from user roles.
Do you think there is any other way to achieve the same result? I appreciate if you could give me an idea about how to create such a module.
I really appreciate any and all input.
You can create a module and add a hook on node form using : hook_form_alter or hook_form_FORM_ID_alter
Using this kind of hook, you can easily modify node form and hide or make read only specific fields, based on whatever you want (user role, field value...)
There are also the hook_node_view_alter() hook and hook_entity_view_alter() hooks that allow you to modify the render array for a node before it is rendered. There you can set field arrays to have '#access' = FALSE so they are hidden, or '#access' = TRUE to show them.
I'm using this to hide some fields if the date in another field of the node has a time in the past (it's a "subscription expires" field). So I didn't need to change the edit form, just the field display.

Resources