1

Possible Duplicate:
I can’t get the SKU value for a commerce product in a rule action

Still trying to skin the same cat. I have a Drupal 7 Commerce site. I've created a Rule which Executes Custom PHP to collect the unit price from an external database via PHP.

I'd show you the Export but it looks -ugly- at this point as Drupal is formatting the code with lots of escs. Anyhoo... It (almost) works except that I need to access the Product ID for the line item.

EVENT: Calculating the sell price of a product
CONDITION: Entity Has Field FIELD: commerce-line-item VALUE: commerce_product
ACTION: Set Unit Price To A Fixed Amount

So the Execute Custom PHP looks like this:

    $data = 'name=value&name1=value1';
    $options = array(
        'method' => 'GET',
        'data' => $data,
        'timeout' => 15,
        'headers' => array('Content-Type' => 'application/x-www-form-urlencoded'),
    );
$result = drupal_http_request('http:test_vendor_site.com?Svc=Start?CartID=12345&Cust=443030&Cntact=2254&ProductID=something', $options);

// Parse the $result to $new_unit_price code in here...

$value = $new_unit_price * 100;
return $value;

...all I need to get this working is to retrieve the Product ID in here so I can add it to the URL I'm passing to drupal_http_request. How do I do this? I thought by adding the Entity Field condition I could access the Product variable for the line item but I'm obviously not addressing them properly.

Any ideas?

TIA,

---JC

marked as duplicate by mpdonadio Jan 22 '13 at 12:08

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.