0

I am using the Charge add-on to connect a website to Stripe payments. I have an action setup whereby a channel entry is created. There are five fields in the channel, four of the fields are text inputs and the last one is a Playa field. The four text inputs are being populated correctly but not the Playa field.

In the code block below, the Playa field is "recipe_purchases_recipe". I am using hidden fields as I only want the form to show the credit card information (removed here for brevity).

This form is embedded in the template as a Stash embed so that I can pass entry variables through. Looking at the code in web inspector I see that the correct variables are coming through, but I can't figure out how to get the Playa field to populate with the entry. I tried {entry_id}, {url_title} and {title} but no luck so far.

How do I populate a Playa field in an entry using the Charge action?

{exp:charge:form
 form_id="charge-form"
 on_success="create_recipe_purchase_entry"
 on_success:recipe_purchases_order_number="{id}"
 on_success:recipe_purchases_customer_name="{customer_name}"
 on_success:recipe_purchases_amount="{plan_amount}"
 on_success:recipe_purchases_recipe="{stash:entry_id}"
 return="/recipes/{segment_2}/thanks"
 return_error="/recipes/{segment_2}/buy"
}
 <input type="hidden" id="customer_name" name="customer_name" value="{exp:zoo_visitor:details}{visitor:member_firstname} {visitor:member_lastname}{/exp:zoo_visitor:details}" />
 <input type="hidden" id="customer_email" name="customer_email" value="{email}" />
 <input type="hidden" id="plan_amount" name="plan_amount" value="{recipe_price}" />
 <input type="hidden" id="recipe_purchases_recipe" name="recipe_purchases_recipe[]" value="{stash:entry_id}" />
   ...       
{/exp:charge:form}

1 Answer 1

0

I would say that this is not as easy as using the params for Charge, the problem is Playa is a complex field with its own tables, so it doesn't store the raw value in the exp_channel_data table, but rather stores a reference to the exp_relationships table.

What I would do is develop a small extension that hooks into the charge event action-update-entry-end, set up an action to update your entry as normal (perhaps update a simple field) and use the hook to catch the data you need, from here you can use the Channel Entries API to populate your playa with PHP.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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