2

I want to change the value of one of my product custom fields when "Checkout completion". I created that custom field myself, with machine name field_prodstat.

How I can do that with the Rules module?

1

Preface: I'm assuming this question is about D7.

Create a custom rule (using the Rules module) like so:

  • Rules Event: checkout completion event.
  • Rules Condition: entity has field, for the field with machine name "field_prodstat" (which will make that field available as a token you can select in subsequent Rules Events and/or Rules Actions).
  • Rules Action: set a data value, for the field with machine name "field_prodstat".

Update

Below is an attempt to also address your comment below this answer, the relevant part of that comment is like so:

I have a content type called "Appointment". When that appointment status = "Accepted Pending Payment" I created a rule to build a new product for that "appointment". So now I have a product related to that appointment. I just want to update "Appointment" status to "Paid" when his product appear in an order with status = invoiced. I don't know if you have any other proposal to do that.

That comment starts revealing your real question, which is pretty different from your original question. To answer your real question is not something that can be explained in just a few phrases. I suggest you have a look at the video tutorial about Removing Items From the Cart Using Rules which demonstrates a scenario which is pretty similar to what you're asking for (in your extra comment). Here is part of what is shown in that video (quote is from that link):

  • Create a rule that loops through all the line items when the order is about to be saved. Have it call a component (rules subroutine) for each line item to see if that line item should be removed.
  • Create the component that does the work. It needs to take two arguments (line item and the order-about-to-be-saved).

To make this also work for your case, I think you'd be close if you only replace the last Rules Action in the used Rules Component by a Rules Action that applies the update you're asking for in your comment.

  • Thanks for your answer -What I should put in : Data selector (Rules Condition ) ? – Media WEB Feb 4 '17 at 19:57
  • @MediaWEB what are the possible options you can select? – Pierre.Vriens Feb 4 '17 at 20:07
  • commerce-order //// commerce-order:owner:... //// commerce-order:commerce-line-items:... – Media WEB Feb 4 '17 at 20:08
  • My turn to ask questions: your question is about "one of my product ..." (custom fields). And your previous comment seems to indicate (1 or more) "line items" (which IMO is not a surprise, since at checkout time you're processing a cart, containing line items). So what exactly is it that you want to change the value for? Just a guess, maybe you do have a specific SKU in mind of some line items for which you want to change the value of your field_prodstat field? Or is it something completely different? Please improve your question to clarify all this. – Pierre.Vriens Feb 4 '17 at 20:16
  • 1
    @MediaWEB : wow, your last comment starts revealing your real question, which is pretty different from your original question. I suggest you integrate your comments below my answer into your original question. So that at least you have a more accurate question. However, to answer your real question is not something that can be done in just a few phrases. So I wouldn't be surprised if your (real) question would be put on hold as "too broad". Not sure how to move forward on this question. PS: your english is fine (even more then good enough). – Pierre.Vriens Feb 4 '17 at 20:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.