Discussions

Rules and product fields, please help

Sorry if this has been discussed before, but I still don't have all the steps for accessing a field in a product.

I have a product with a custom field "customer" and I want to create a rule so when an order is created, the customer field is populated with the customer name from the order.

I know I have to use "Entity has field" so I did (or data compare, no luck with this one)

But in the actions I am guessing I have to add "set data value" witch doesn't allow me to use any field.

Please tell me the steps and options I need. Also I imagine Rules is not so buggy now...

Thanks

Posted: Mar 20, 2012

Comments

pitxels on March 20, 2012

This is my rule now but still not working

{ "rules_owner_update" : {
    "LABEL" : "Owner Update",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "commerce_checkout" ],
    "ON" : [ "commerce_checkout_complete" ],
    "IF" : [
      { "entity_is_of_type" : {
          "entity" : [ "commerce-order:commerce-line-items:0" ],
          "type" : "commerce_product"
        }
      }
    ],
    "DO" : [
      { "entity_query" : {
          "USING" : {
            "type" : "commerce_product",
            "property" : "field_owner",
            "value" : [ "commerce-order:owner:name" ]
          },
          "PROVIDE" : { "entity_fetched" : { "entity_fetched" : "Fetched entity" } }
        }
      }
    ]
  }
}

pitxels on April 6, 2012

Is this very tricky? or it just hard to get help in the forums? to much questions I guess?