custom product choices not showing in order reports

6 views
Skip to first unread message

mda

unread,
Oct 28, 2007, 8:29:24 PM10/28/07
to Satchmo users
I'm using the "Custom Product" feature instead of product options.

It is working ok, but the particular values selected are not showing
up in:
- the "New Orders" summary in the admin dashboard
- the /contact/order list
- the /contact/order/1 detail

Could someone summarize what I'd need to change to get that to
be shown?

Thanks.

mda

unread,
Nov 4, 2007, 3:08:22 PM11/4/07
to Satchmo users
I'm still suffering with this.
(In fact I'm beginning to regret taking the approach of using the
"Custom Product"
stuff at all, which seems to be an amalgam of what one committer
needed for one
client, not something really architected de novo.)

I need the particular choices made to be available in the confirmation
email
as well as in the admin reports.
So far as I can tell however, this can't easily be done -- the saved
data is tied
to the shop_cart entity, not the contact_order entity, and I don't see
a path
of joins between them.

So maybe I'm going to have to redo my whole approach and go back
to the Product Variation thing, where there is a reified product
entity
for every possible cross-product of option values?

Chris Moffitt

unread,
Nov 4, 2007, 9:43:37 PM11/4/07
to satchm...@googlegroups.com
I took a look at this code in a little more detail and I think you may be right.  It looks like the data does not get copied from the cart to the actual order.  I suspect this is just a bug that slipped in with this product type. 

Anyway, I don't think the solution is too terribly difficult.  I think the best option is to create a new Model called CustomFields with the name, value pairs and link it to the orderitem.  That way, you'll have access to everything when you're sending emails, etc.  It will look & behave sort of like the DownloadLink model.

Because I am convinced we need to do another look at our Product, I'm wary of making yet another change right now. I'm just struggling to figure out the best solution.  In the meantime, the fix I mention above should work and might be more useful than trying to go with the existing behavior.

-Chris

mda

unread,
Nov 5, 2007, 2:15:01 AM11/5/07
to Satchmo users
(I'm stuck with proceeding in this direction; I just tried again to do
the product variation
thing and ended up with over 200 sub products, and
the admin slowed to a crawl and/or gave an error depending on the page
attempted.
so back to this custom product solution.)

my knowledge of python and of django is limited, but here is what i've
done so far just working in the dark.

Added to satchmo/contact/models.py

from satchmo.product.models import Product, DownloadableProduct,
CustomTextField
....
class CustomFieldValue(models.Model):

"""
The value of some product_customtextfield chosen by a user for
some
contact_orderitem
"""
order_item = models.ForeignKey(OrderItem)
custom_field = models.ForeignKey(CustomTextField)
value = models.CharField(max_length=200)

I ran manage.py sql contact add ran the generated "CREATE TABLE".

added inner loop in satchmo/payment/comment/pay_ship.py (which seems
to be where
the cart is converted to an order):

# Add all the items in the cart to the
order
for item in cart.cartitem_set.all():
new_order_item = OrderItem(order=new_order,
product=item.product, quantity=item.quantity,
unit_price=item.unit_price, line_item_price=item.line_total)
new_order_item.save()
# for each custom text field in the cart item, save a row in
contact_customfieldvalue
for details in item.cartitemdetails_set.all():
new_field_value =
CustomFieldValue(order_item_id=new_order_item.id,
custom_field_id=details.customfield_id, value=details.detail)
new_field_value.save()
new_order.recalculate_total()

All I know is that the above seems to be syntactic python.
So the good news is my site is still running.
The bad news is that my new table is still empty after doing a
checkout,
so something is wrong with my inner loop code.

Anybody see what is wrong?

-mda

Chris Moffitt

unread,
Nov 5, 2007, 9:48:26 AM11/5/07
to satchm...@googlegroups.com
I can't see what's wrong but upon thinking about this some more, I thought of another possibly easier solution.  The current order model has a notes field that isn't used.  You could just put a string with all of the custom details into the order notes.    That should be even more straightforward and not require any model changes.

-Chris

mda

unread,
Nov 5, 2007, 10:56:16 AM11/5/07
to Satchmo users

On Nov 5, 6:48 am, "Chris Moffitt" <ch...@moffitts.net> wrote:
> I can't see what's wrong

in particular i wasn't sure whether

for details in item.cartitemdetails_set.all():

was the right way to get at the shop_cartitemdetails table
from the shop_cartitem row.

if i have to i'll do that but ultimately i want admin reports and CSV
exports that break out values into separate columns.
I could parse it out of course; that just adds a bit more to
my speed-learning of python :)

-mda


mda

unread,
Nov 5, 2007, 10:59:04 AM11/5/07
to Satchmo users
btw, perhaps another issue is that i was testing with the autosuccess
payment module.
is it possible that it doesn't go through pay_ship_save() ?

Chris Moffitt

unread,
Nov 5, 2007, 11:04:42 AM11/5/07
to satchm...@googlegroups.com
Yes, I believe it does have it's own custom flow.

-Chris

mda

unread,
Nov 5, 2007, 11:27:06 AM11/5/07
to Satchmo users
hmmm, i did an apache restart on general principles, and now I'm
getting
an incomprehensible "NoReverseMatch" exception on /shop/checkout/
while the rest of the store and the admin continue to work.
Nothing useful in satchmo.log (is there ever?).

Any suggestions? I don't see how me altering existing files could
possible mess with url mapping.

the traceback includes:
# /group/uhurupies.com/satchmo/satchmo/payment/views.py in
contact_info
# return common_contact.contact_info(request)
# /group/uhurupies.com/satchmo/satchmo/payment/common/views/
common_contact.py in contact_info
# url = lookup_url(paymentmodule, 'satchmo_checkout-step2')
# /group/uhurupies.com/satchmo/satchmo/payment/urls.py in lookup_url
# url = urlresolvers.reverse(name)

Maybe there is some buried inner exception about getting contact?

Chris Moffitt

unread,
Nov 5, 2007, 12:07:03 PM11/5/07
to satchm...@googlegroups.com
These types of bugs can be tricky to find.  In this thread, Bruce gives a tip for getting a more useful error message:
http://groups.google.com/group/satchmo-users/browse_thread/thread/394ebd1a00689ac5#

I also added a note on the wiki -
http://www.satchmoproject.com/trac/wiki/InstallationHints

-Chris

mda

unread,
Nov 5, 2007, 6:26:07 PM11/5/07
to Satchmo users
the command-line technique reproduced the problem but was no more
clear.
however, through the tried-and-true technique of progressive
commenting
out of diffs, I did narrow it down to my changes to pay_ship.py, which
I
have now fixed.
Beats me why it caused this action at a distance.

Now my problems include:

1. If I enable email for "autosuccess", I get an exception
NameError at /shop/checkout/auto/
global name 'orderToProcess' is not defined
(I'm not sure why "autosuccess" is even managing its own email anyhow)

2. For some reason my install has decided not to do checkout over
https anymore.
I have both the master and subsidiary checkboxes enabled for this
in the admin. And it used to work. But now, even if I enter a "https:"
url to help it along as it were, it redirects back to "http:"

-mda

Chris Moffitt

unread,
Nov 5, 2007, 6:51:38 PM11/5/07
to satchm...@googlegroups.com
1. If I enable email for "autosuccess", I get an exception
NameError at /shop/checkout/auto/
global name 'orderToProcess' is not defined
(I'm not sure why "autosuccess" is even managing its own email anyhow)


I think this was fixed in changeset 870 - http://www.satchmoproject.com/trac/changeset/870

2. For some reason my install has decided not to do checkout over
https anymore.
I have both the master and subsidiary checkboxes enabled for this
in the admin. And it used to work. But now, even if I enter a "https:"
url to help it along as it were, it redirects back to "http:"

It could be  something in your webserver config.  Did you change anything there?

-Chris


Bruce Kroeze

unread,
Nov 5, 2007, 7:10:48 PM11/5/07
to satchm...@googlegroups.com
On 11/5/07, mda <m...@discerning.com> wrote:
1. If I enable email for "autosuccess", I get an exception
NameError at /shop/checkout/auto/
global name 'orderToProcess' is not defined
(I'm not sure why "autosuccess" is even managing its own email anyhow)


Good point, fixed in rev 871. 

Reply all
Reply to author
Forward
0 new messages