Skip to main content
added 23 characters in body
Source Link

As I said on IRC, a line item doesn't store the id of the product display in a way that Rules can understand. This is because product displays are not required for Commerce to work.

However, line items have a "commerce_display_path" field that stores the url from which the product was added, so in your case it would probably look like "node/1", or whatever the node id is.

What you need to do is: Write a custom Rules action that takes the line item, initializes the wrapper, gets the value of commerce_display_path, explodes the string, takes the nid, loads the node, returns it.

Example code:
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item$commerce_line_item);
$url = $line_item_wrapper->commerce_display_path->value();
$url_parts = explode('/', $url);
$nid = $url_parts[1];
return node_loadarray($nid'node_fetched' => $node);
Place

Place this in a custom rules action, and you're good to go.

You can then use your action in a component to get the product display whose fields you can then access.

As I said on IRC, a line item doesn't store the id of the product display in a way that Rules can understand. This is because product displays are not required for Commerce to work.

However, line items have a "commerce_display_path" field that stores the url from which the product was added, so in your case it would probably look like "node/1", or whatever the node id is.

What you need to do is: Write a custom Rules action that takes the line item, initializes the wrapper, gets the value of commerce_display_path, explodes the string, takes the nid, loads the node, returns it.

Example code:
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$url = $line_item_wrapper->commerce_display_path->value();
$url_parts = explode('/', $url);
$nid = $url_parts[1];
return node_load($nid);
Place this in a custom rules action, and you're good to go.

You can then use your action in a component to get the product display whose fields you can then access.

As I said on IRC, a line item doesn't store the id of the product display in a way that Rules can understand. This is because product displays are not required for Commerce to work.

However, line items have a "commerce_display_path" field that stores the url from which the product was added, so in your case it would probably look like "node/1", or whatever the node id is.

What you need to do is: Write a custom Rules action that takes the line item, initializes the wrapper, gets the value of commerce_display_path, explodes the string, takes the nid, loads the node, returns it.

Example code:
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $commerce_line_item);
$url = $line_item_wrapper->commerce_display_path->value();
$url_parts = explode('/', $url);
$nid = $url_parts[1];
return array('node_fetched' => $node);

Place this in a custom rules action, and you're good to go.

You can then use your action in a component to get the product display whose fields you can then access.

Source Link

As I said on IRC, a line item doesn't store the id of the product display in a way that Rules can understand. This is because product displays are not required for Commerce to work.

However, line items have a "commerce_display_path" field that stores the url from which the product was added, so in your case it would probably look like "node/1", or whatever the node id is.

What you need to do is: Write a custom Rules action that takes the line item, initializes the wrapper, gets the value of commerce_display_path, explodes the string, takes the nid, loads the node, returns it.

Example code:
$line_item_wrapper = entity_metadata_wrapper('commerce_line_item', $line_item);
$url = $line_item_wrapper->commerce_display_path->value();
$url_parts = explode('/', $url);
$nid = $url_parts[1];
return node_load($nid);
Place this in a custom rules action, and you're good to go.

You can then use your action in a component to get the product display whose fields you can then access.