Hi,
I think I understand the strange behaviour. I'll try to explain it:
The first time you select a shipping the
request.form['shipping_method_code'] doesn't exist, hence it will be created
with the value you have selected in the wizard
(request.form['shipping_method_code'] == 'usps.D-16'). In the next wizard
getpaid gets the shipping cost using the value from the request. This time
it works. When you go back from this wizard to the previous one (to the one
you selected the shipping) the request.form['shipping_method_code'] exists
already with the previous selected value. Now you select the shipping and
continue. Getpaid doesn't create the request.form['shipping_method_code']
because it already exists, so it APPENDS (creating a list) the new value
(request.form['shipping_method_code'] == ['usps.D-16', 'usps.D-16']). In the
next wizard Getpaid tries to get the shipping cost using the value from the
request, but this time resulting in NO success, because the value is a list
of two strings and doesn't match with any of the shipping methods. So
getpaid sets the cost to 0 and the shipping method to none. The next time
you go back the request.form hasn't the key shipping_method_code, so it
works as in the first time.
I don't know where getpaid accomplishes all this, but I have a patch that
correct this strange behaviour. I know it's not the perfect solution, but
for now it works. Maybe someone that knows getpaid better than me can
correct the bug in the origin.
Here is the patch:
--- Products/PloneGetPaid/checkout.py.orig 2009-06-23
23:42:42.000000000 +0000
+++ Products/PloneGetPaid/checkout.py 2009-06-23 23:25:11.000000000 +0000
@@ -714,6 +714,8 @@
and returns a list of them for the template to display and the user
to choose among.
"""
+ try: del(self.request.form['shipping_method_code'])
+ except: pass
siteroot = getToolByName(self.context,
"portal_url").getPortalObject()
ship_service_names =
IGetPaidManagementOptions(siteroot).shipping_services
2009/6/23 Juan Carlos Coruña <[email protected]>
> Hi,
>
> I'm also trying to track down the same bug. It's a strange behaviour one
> time it works ok and the next time it fails, and so on...
>
> I have used the pdb and I followed the code till PloneGetPaid/_patch.py and
> there I get lost. I suspect the bug is in _patch.py, but I cannot assure it.
> Maybe this can be clue for others trying this. I'll continue to track down
> this bug. If I make some progress I will inform about it.
>
> 2009/6/23 Rob LaRubbio <[email protected]>
>
> I'm trying to track down a bug in getpaid that seems to allow a user to get
>> free shipping. I've been able to get to a point were I can reproduce it,
>> now I'm looking for pointers or help on why it is occuring.
>>
>> I've got a simple setup of Plone 3.1.6 with GetPaid 0.7.9 (I'm using the
>> svn checkout of the buildout). I've marked a couple of items as shippable
>> and have written my own shipping addon that talks to USPS.
>>
>> The free shipping issues happens when a user walks through the checkout
>> process up to the 'checkout-review-pay' step. At this point if the user
>> hits the 'Back' button provided on the page (not the browser back), they
>> return to the 'checkout-select-shipping' step with a hidden element that
>> holds their previous shipping choice. This input element is the same as the
>> input radio select on the page. This shouldn't be a problem since I would
>> expect to get both the hidden value and the radio select in an array, and it
>> looks like the code expects that as well since the getShippingMethodCode()
>> does this:
>>
>> if isinstance( service_code, list):
>>> service_code = service_code[-1]
>>>
>>
>>
>> however it seems I'm getting an empty array instead of an array with two
>> values. For some clarity the checkout-shipping-select html essentially
>> looks like this:
>>
>> <form action="https://nwei.org/@@getpaid-checkout-wizard"
>>> method="post" enctype="multipart/form-data">
>>> <input type="hidden" name="shipping_method_code"
>>> value="usps.D-16"></div>
>>
>> <I removed all the other hidden inputs>
>>>
>>> <input checked type="radio"
>>> name="shipping_method_code"
>>> value="usps.D-16" />
>>>
>>> <input type="submit" class="button context"
>>> id="form.actions.continue"
>>> name="form.actions.continue" value="Continue" />
>>> </form>
>>
>>
>> As far as I can tell the code should work. I'm not clear on why
>> self.request.get('shipping_method_code') is [] on the second submit instead
>> of ['usps.D-16', 'usps.D-16']? Also if I submit the form, then hit 'back'
>> again it works ok since there is no hidden element for an empty array added.
>>
>> Anyway if anyone has some suggestions on where to look I would really
>> appreciate it. Thanks.
>>
>> -Rob
>>
>> >>
>>
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"getpaid-dev" 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/getpaid-dev?hl=en
-~----------~----~----~----~------~----~------~--~---