I use drupal commerce. I have several entityform type. Each product has entity reference to one of these forms. How to page redirect to referenced form url when a product added to cart.
Thanks
You want to use Rules for this. It should already be installed since Drupal Commerce requires it.
Create a new rule by going to Admin > Config > Workflow > Rules, and click Add rule.
A rule consists of 3 parts.
The event that initiates the rule would be After adding a product to the cart
.
Use this to find your reference field;
Add a rule entity had field
and check if the commerce_line_item
(I suppose you get that by default) has a field commerce_product
. Then add a second check to see if commerce_line_item:commerce_product
has a field entity_reference
.
Depending on where you created the field you might require several layers.
You want to use the Page redirect
action in the system
group. Make sure to click the data selector
button, then you can search the redirect path. It suppose should look something like commerce_line_item:commerce_product:field_reference:url
.
[commerce-product:field_reference]
gets the form name as url but [commerce-product:field_reference:url]
doesn't get the form url. Page redirected to front page
Commented
Dec 23, 2015 at 19:23
data selection
widget (the auto fill input) to find the exact names. If the first provides a url, use it to do the redirect.
Commented
Dec 23, 2015 at 20:05
:url
. I can enter only with direct input. May :url
token unsupperted for entity form via entity reference? Forms url data looks like this: "weight" : "0", "paths" : { "submit" : { "source" : "eform\/submit\/form-3", "alias" : "the_url_i_need", "language" : "und" } }
Commented
Dec 23, 2015 at 20:32
load the entity by id
first. Perhaps the url will become available then. Order does matter, so make sure this action is performed first. If the data selector does not have it, it does not exist.
Commented
Dec 23, 2015 at 20:37
[commerce-product:field_reference:id]
works without load the entity by id
but [commerce-product:field_reference:url]
doesnt work with or without load the entity by id
and still url token not provided by data selector.
Commented
Dec 23, 2015 at 20:49