I Broke one thing fixing another

jrwhipjrwhip Member
in General edited December 2014
After some tinkering my cart was working well. However I had some code placed in the "Add custom form fields to your checkout" section of the configuration page, and apparently I accidentally replaced it with code that was suppose to be in the "Add custom header and footer code to your templates" on the same page.

The problem is I can't seem to figure out how to get it back to the way it was. I have two pieces of code which are suppose to be in this custom fields section:
{% if Referred_By is not defined %}
	{% set Referred_By = "" %}
	{% for key, custom_field in custom_fields %}
		{% if key == "Referred_By" %}
			{% set Referred_By = custom_field.value %}
		{% endif %}
	{% endfor %}
{% endif %}

And:
<div class="fc-form-group" data-fc-error-for="Referred_By" data-fc-error-class="fc-alert-container--error">
	<div class="col-sm-8 col-sm-offset-3">
		<div class="fc-input-group-container fc-input-group-container--active">
			<label class="fc-input-group-container__title fc-input-group-container__title--forced fc-form-label">
				Referred by…
			</label>
			<div class="fc-form-group">
				<p>How did you hear about us?</p>
				<input type="text" id="Referred_By" name="Referred_By" placeholder="" autocomplete="off" class="fc-form-control" aria-required="true" value="{{ Referred_By }}" data-fc-required>
			</div>
		</div>
		<div class="fc-alert fc-alert--danger hidden" data-fc-error-for="Referred_By" data-fc-error-class="show,hidden">
	        <div class="">Please tell us how you heard about us.</div>
	    </div>
	</div>
</div>

You previously helped me get it correct in this thread:
https://forum.foxycart.com/discussion/comment/50151#Comment_50151

I have gone over the thread several times, as well as the documentation and I can't seem to figure it out. Which is frustrating since I did it before.

Can you help me figure out what I am doing wrong?

Also I see this as being a potentially big problem. No way to revert to a previous state. I need a undo button or a backup option. Do you have anything like that?
Comments
  • winstonwinston FoxyCart Team
    @jrwhip

    I just tested this out on my store and the code you have above works perfectly. Could you link or whisper the store you're working on so I could investigate a bit further?

    Here's what I saw (i was testing on a customized store) http://cl.ly/image/272U1m2l1L31

    That was with appending
    &h:Referred_By=Winston
    
    to the end of the product link. I'm happy to debug further if you can point me towards your store.
  • Am I putting the code in the right order? How do you have it exactly pasted into your store?
  • fc_adamfc_adam FoxyCart Team
    @jrwhip,

    Looking at your form - I don't see a "Referred_By", but I do see a "referral_source". Is that the field you're wanting included in the cart? If so - you'll need to change the following line like so:
    {% if key == "referral_source" %}
    
  • Thanks! I can't believe I missed that. It's working great.
Sign In or Register to comment.