Foxy Forum Status

We're no longer responding to questions via our forum, but we will keep it up for historical reasons. If you can't find the answer you're looking for, please visit our knowledge base or contact us. If there's enough interest in the future, we may bring the forum back.

Custom fields and subscription data feed

jrwhipjrwhip Member
I am using your php script for the transition data feed. I was wondering if you could help me with using custom field name values.

for instance I have a custom field called referral_source

It seems like your example code puts the data into an array called custom_fields

$custom_fields = array();
if (!empty($transaction->custom_fields)) {
foreach($transaction->custom_fields->custom_field as $custom_field) {
$custom_fields[(string)$custom_field->custom_field_name] = (string)$custom_field->custom_field_value;
}
}

How are these fields named?
Can you give me an example of how I can get referral_source out
Comments
  • fc_jedfc_jed FoxyCart Team
    @jrwhip

    Just so we're on the same level here, the custom_fields are the fields that you included in Add custom form fields to your checkout and not a custom product option. Some people get that confused, so it's worth noting.

    Let's say for example you have a custom input field "referral_source" with a value of "internet", you would then arrive with something like this in your datafeed:
    <custom_fields>
    <custom_field>
    <custom_field_name><![CDATA[referral_source]]></custom_field_name>
    <custom_field_value><![CDATA[internet]]></custom_field_value>
    <custom_field_is_hidden><![CDATA[0]]></custom_field_is_hidden>
    </custom_field>
    </custom_fields>
    So, what you would need to do is to iterate over each custom_field and look for a custom_field_name that is equal to "referral_source". Does that help?
  • Thanks. I will see If I can find it using that.
Sign In or Register to comment.