Josh,

Your code works well. Thanks.
There are two problems I have found:
1) The anti-spam features of 
http://docs.djangoproject.com/en/dev/ref/contrib/comments/
are not being employed.
2) The order note is not included in the invoice or the packing slip.

I've been working on fixing #2 but haven't got it working so far. Has
anyone had success fixing issue #2?

The feature cannot be used in production unless both of these are
working.


On Oct 29, 6:45 pm, Josh <[email protected]> wrote:
> I figured out what I was doing wrong, i needed to import forms from
> django, not payment.  Anyways, for posterity, in case anyone is ever
> looking to do this in the future, here is the complete solution to add
> anotesfield during checkout which is saved to the productorder.
>
> inside localsite/models.py (it probably doesnt have to be here but
> that's what I did) put:
>
> from signals_ahoy.signals import form_init
> from payment.forms import SimplePayShipForm
> from django import forms
>
> def add_order_note(sender, form, **kwargs):
>     """Add a Note field to theorder."""
>     if 'notes' not in form.fields:
>         notes_attrs = {'rows': 4, 'cols': 50}
>         form.fields['notes'] = forms.CharField(label='Notes',
> required=False, help_text='(Optional) Any special instructions, etc.',
>
> widget=forms.Textarea(attrs=notes_attrs))
>
> form_init.connect(add_order_note, sender=SimplePayShipForm)
>
> Then copy base_pay_ship.html from payment->templates->shop->checkout
> to your local templates folder in shop->checkout (so if your local
> templates folder is called templates base_pay_ship.html would be in
> templates/shop/checkout/).  Open the copy and  before the else of {%
> if cart.is_shippable %} put:
>
> {% if form.notes%}
>     <h4>OptionalNotes/Comments</h4>
>     <p id="notes">{{ form.notes}}</p>
> {% endif %}
>
> so that section will look like this:
>
> {% if cart.is_shippable %}
>
>     {% if form.shipping_hidden %}
>          {{ form.shipping }}
>           </table>
>     {% else %}
>          <tr><td><h4>{% trans "Shipping Information" %}</h4></td></tr>
>              </table>
>              {% block shipping_table %}
>              <div id="shipping">
>                 {% if form.shipping_description or
> form.shipping.field.choices|length_is:1 %}
>                 <label for="id_shipping">{% trans "The following
> shipping method will be used" %}:</label>
>                 {% else %}
>                 <label for="id_shipping">{% trans "Please choose your
> preferred shipping method" %}</label>
>                 {% endif %}
>                 {{ form.shipping }}
>                 {% if form.shipping_description %}<br/>{{ 
> form.shipping_description }}{% endif %}
>
>                 {% if form.shipping.errors %}***
> {{ form.shipping.errors|join:", " }}{% endif %}
>                 </div>
>                 {% endblock %}
>             {% endif %}
>
>             {% if form.notes%}
>                 <h4>OptionalNotes/Comments</h4>
>                 <p id="notes">{{ form.notes}}</p>
>             {% endif %}
>     {% else %}
>
>         <tr><td colspan="2"><h4>{% trans "There are no items in thisorderto 
> ship." %}</h4></td></tr>
>         <tr><td colspan="2"> {{ form.shipping }} </td></tr>
>     </table>
>
> {% endif %}
>
> Hopefully this helps someone, i think i need to learn more about
> signals.
>
> -Josh
>
> On Oct 22, 1:25 pm, Josh <[email protected]> wrote:
>
> > I'm trying to do this and I am a bit confused by what Davis said.
> > Could someone help me out?  In localsite I made a models.py I added:
>
> > from signals_ahoy.signals import form_init
> > from payment.forms import SimplePayShipForm
> > from payment import forms
>
> > def add_order_note(sender, form, **kwargs):
> >     """Add a Note field to theorder."""
> >     if 'notes' not in form.fields:
> >         notes_attrs = {'rows': 4, 'cols': 50}
> >         form.fields['notes'] = forms.CharField(label='Notes',
> > required=False, help_text='(Optional) Any special instructions, etc.',
>
> > widget=forms.Textarea(attrs=notes_attrs))
>
> > form_init.connect(add_order_note, sender=SimplePayShipForm)
>
> > then in base_pay_ship.html I added:
> > {% if form.notes%}
> > <h4>OptionalNotes/Comments</h4>
> > <p id="notes">{{ form.notes}}</p>
> > {% endif %}
>
> > Now I'm getting:
> > AttributeError at /checkout/credit/
>
> > 'module' object has no attribute 'CharField'
>
> > Anyone know whats wrong?
>
> > Thanks!
> > -Josh
>
> > On Sep 14, 8:40 am, Bruce Kroeze <[email protected]> wrote:
>
> > > Any version that has signals_ahoy should do.
>
> > > On Tue, Sep 14, 2010 at 5:28 AM, Alessandro Ronchi <
>
> > > [email protected]> wrote:
> > > > which satchmo version supports this code? also 0.8.1 ?
>
> > > > 2010/9/9 davis <[email protected]>:
> > > > > Here's what I did:
>
> > > > > def add_order_note(sender, form, **kwargs):
> > > > >    """Add a Note field to theorder."""
> > > > >    if 'notes' not in form.fields:
> > > > >        notes_attrs = {'rows': 4, 'cols': 50}
> > > > >        form.fields['notes'] = forms.CharField(label='Notes',
> > > > > required=False,
> > > > >                                    help_text='(Optional) Any special
> > > > > '
> > > > >                                    'instructions, etc.',
>
> > > > > widget=forms.Textarea(attrs=notes_attrs))
>
> > > > > form_init.connect(add_order_note, sender=SimplePayShipForm)
>
> > > > > And I added the 'notes' field to the base_pay_ship.html template:
>
> > > > > {% if form.notes%}
> > > > > <h4>OptionalNotes/Comments</h4>
> > > > > <p id="notes">{{ form.notes}}</p>
> > > > > {% endif %}
>
> > > > > On Sep 8, 9:38 am, lzantal <[email protected]> wrote:
> > > > >> Hi,
>
> > > > >> I tryed to use form_init signal but mynotesnever got saved.
> > > > >> Did you implemented this with that signal? If so could you share your
> > > > >> implementation?
> > > > >> I prefer to use signals over altering satchmo.
>
> > > > >> Thank you
>
> > > > >> lzantal
>
> > > > >> On Sep 3, 7:46 pm, davis <[email protected]> wrote:
>
> > > > >> > Satchmo was patched a while back to save theorderformnotes, so
> > > > >> > instead of altering Satchmo you can use a form_init signal 
> > > > >> > listener to
> > > > >> > add the field to the form.
>
> > > > >> > On Sep 3, 2:25 pm, lzantal <[email protected]> wrote:
>
> > > > >> > > Yes it is:)
> > > > >> > > Looks pretty good.
>
> > > > >> > > lzantal
>
> > > > >> > > On Sep 3, 11:00 am, Stuart Laughlin <[email protected]> 
> > > > >> > > wrote:
>
> > > > >> > > > Perfect timing... I just finished implementing this myself...
>
> > > > >> > > > Isn't that always the way?!?  :) :)
>
> > > > >> > > > Here's what I did...
>
> > > > >> > > >    1) add 'notes' field to payment.forms.PaymentContactInfoForm
> > > > >> > > >      notes= forms.CharField(max_length=200, label=_('Shipping
> > > > >> > > >Notes'), required=False)
>
> > > > >> > > >    2) update line of code that createsOrderin
> > > > >> > > > payment.utils.get_or_create_order (line 45 or so)
> > > > >> > > >      order=Order(contact=contact,notes=data['notes'])
>
> > > > >> > > >    3) addnotesfield to my template (shop/checkout/form.html for
> > > > me)
> > > > >> > > >       <tr class="shiprow"><td><label>{% trans "Notes"
> > > > >> > > > %}</label></td><td>{{ form.notes}}</td></tr>
> > > > >> > > >       {% if form.notes.errors %}<tr><td class="error"
> > > > colspan="2">***
> > > > >> > > > {{ form.notes.errors|join:", " }}</td></tr>{% endif %}
>
> > > > >> > > > Pretty similar to yours in concept, I think.
>
> > > > >> > > > Thanks for the input!!
>
> > > > >> > > > --Stuart
>
> > > > >> > > > On Fri, Sep 3, 2010 at 12:35 PM, lzantal <[email protected]>
> > > > wrote:
> > > > >> > > > > Hi,
>
> > > > >> > > > > I use this quick hack. it works great but you habe to keep in
> > > > mind
> > > > >> > > > > that it alters satchmo core so you need to keep your eye on 
> > > > >> > > > > it
> > > > when
> > > > >> > > > > you upgrade your satchmo.
> > > > >> > > > > 1; Add your note input field to
> > > > templates/shop/checkout/form.html
> > > > >> > > > >   lets assume its name="ordernote"
> > > > >> > > > > 2; Add this in sathcmo/apps/payment/views/contact.py into
> > > > function
> > > > >> > > > > contact_info(request, **kwargs):
> > > > >> > > > >  on line 70 in my version right after if form.is_valid():
> > > > >> > > > >  order.notes= new_data["ordernote"]
> > > > >> > > > >  order.save()
>
> > > > >> > > > > That's all. Now the note is saved into theOrdermodelsnotes
> > > > field.
>
> > > > >> > > > > Hope it helps
>
> > > > >> > > > > lzantal
>
> > > > >> > > > > On Sep 3, 8:30 am, Stuart Laughlin <[email protected]>
> > > > wrote:
> > > > >> > > > >> Did anyone ever figure out how to getordernotesworking? The
> > > >notes
> > > > >> > > > >> field is on theOrdermodel and i see right where I want to 
> > > > >> > > > >> put
> > > > the
> > > > >> > > > >> field on step 1 of the checkout process.. so close I can 
> > > > >> > > > >> taste
> > > > it! But
> > > > >> > > > >> I'm having some trouble figuring out exactly what's going 
> > > > >> > > > >> on in
> > > > the
> > > > >> > > > >> backend and how to getordernotesworking properly. There's
> > > > some
> > > > >> > > > >> pretty dynamic code in there!
>
> > > > >> > > > >> Thanks!
>
> > > > >> > > > >> --Stuart
>
> > > > >> > > > >> On Thu, Apr 1, 2010 at 9:55 PM, davis <[email protected]> 
> > > > >> > > > >> wrote:
> > > > >> > > > >> > This is something I've been wanting to do as well, but I
> > > > haven't had
> > > > >> > > > >> > the time to figure it out. Hopefully, someone else has 
> > > > >> > > > >> > done
> > > > it.
>
> > > > >> > > > >> > On Apr 1, 8:16 pm, GuyBrush <[email protected]> 
> > > > >> > > > >> > wrote:
> > > > >> > > > >> >> Is it possible to use thenotesfield in the checkout page?
> > > > I'm trying
> > > > >> > > > >> >> to use it as a Gift Note form.
> > > > >> > > > >> >> I successfully added the form to the page but I'm not 
> > > > >> > > > >> >> able
> > > > to savenotes.
> > > > >> > > > >> >> I have been looking at satchmo code for the last couple 
> > > > >> > > > >> >> of
> > > > days + trying
> > > > >> > > > >> >> to understand django forms better but still don't know 
> > > > >> > > > >> >> how
> > > > to do this.
>
> > > > >> > > > >> >> Can any one give me some clues?
> > > > >> > > > >> >> Any help is appreciated.
> > > > >> > > > >> >> Thanks!
>
> > > > >> > > > >> > --
> > > > >> > > > >> > You received this message because you are subscribed to 
> > > > >> > > > >> > the
> > > > Google Groups "Satchmo users" group.
> > > > >> > > > >> > To post to this group, send email to
> > > > [email protected].
> > > > >> > > > >> > To unsubscribe from this
>
> ...
>
> read more »

-- 
You received this message because you are subscribed to the Google Groups 
"Satchmo users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/satchmo-users?hl=en.

Reply via email to