vsoch / freegenes

FreeGenes BioNode with Django
https://vsoch.github.io/freegenes/
Mozilla Public License 2.0
2 stars 4 forks source link

Order Addresses Not Populating Shipments #166

Closed hverdonk closed 4 years ago

hverdonk commented 4 years ago

Is your feature request related to a problem? Please describe. When a user requests a distribution, their shipping address data is not sent to the shipper. This means that when a new request enters the shipment queue, the "shipping to" address data doesn't autopopulate when "load addresses" is clicked, and I receive no Formspree email notifying me of the recipient's address. Essentially, I have no idea what address to ship to.

Describe the solution you'd like Some way to collect the user's shipping address when they check out. In addition, I'd like the correct address to automatically populate the appropriate fields when generating a shipping label.

Describe alternatives you've considered The absolute minimum viable solution would be to bring the Formspree email back, but I'd strongly prefer the above solution.

Anything else?

vsoch commented 4 years ago

@hverdonk this was requested to be refactored so that the address is saved to the database when they submit the order. Formspree isn't used anymore, but instead sendgrid. The button to populate the fields was intentionally removed because the data can come from the database, for the addresses that were added after this feature was introduced.

So - if you have an order that doesn't have an address, it means that you'd need to manually enter it.

vsoch commented 4 years ago

I discussed this in detail here https://github.com/vsoch/freegenes/pull/122

Koeng101 commented 4 years ago

So - if you have an order that doesn't have an address, it means that you'd need to manually enter it.

As far as I could see, the order system never collected the address in the first place. So now we have to manually enter it every time.

hverdonk commented 4 years ago

I also didn't receive a SendGrid email notifying me that an order had been created, though it had previously been working.

vsoch commented 4 years ago

The logic is implemented to save the address and send the email at checkout, see https://github.com/vsoch/freegenes/blob/master/fg/apps/orders/views/orders.py#L206.

Per discussion over two weeks ago I had suggested that the new workflow be fully tested, and maybe this was forgotten?

The first step would be to go through checkout, and submit as a new order, and then (let me know when it's checked out) and I can look at the database values for the address. It should be hitting those endpoints to create the address given that the form is valid.

vsoch commented 4 years ago

I'm testing now - it seems to be skipping the checkout entirely after the MTA upload, let me see if I can tell what's going on.

vsoch commented 4 years ago

Just figured it out - the bug was introduced with the changes in status. When the user uploads the MTA, the status is changed to "Awaiting Countersign" but then that means the cart cannot be found, so the order is never finished processing.

hverdonk commented 4 years ago

Ah, that makes sense! We'd definitely tested it prior to that - I remember getting the SendGrid email and being glad that it included special instructions. Thank you!

vsoch commented 4 years ago

Yeah me too! I'm working on it now, should get the fix in soon! Both these issues that were opened should be resolved after that. The oversight was that "Awaiting Countersign" shouldn't be given right after upload of the MTA, but after upload of the MTA and checkout.

vsoch commented 4 years ago

okay walking through this - checkout form is back!

image

hverdonk commented 4 years ago

Woo! Thank you! I'll test it out myself in an hour or so after lunch, but I'll tentatively say it's solved.

vsoch commented 4 years ago

date_ordered is defined

image

Did you get an email? I see 202 response in the logs.

uwsgi_1      | This is an order for a dinosaur.
uwsgi_1      | 202
uwsgi_1      | Server: nginx
uwsgi_1      | Date: Fri, 22 Nov 2019 20:43:32 GMT
uwsgi_1      | Content-Length: 0
uwsgi_1      | Connection: close
uwsgi_1      | X-Message-Id: k6OkM9voRTq1Bnp3w7UiPA
uwsgi_1      | Access-Control-Allow-Origin: https://sendgrid.api-docs.io
uwsgi_1      | Access-Control-Allow-Methods: POST
uwsgi_1      | Access-Control-Allow-Headers: Authorization, Content-Type, On-behalf-of, x-sg-elas-acl
uwsgi_1      | Access-Control-Max-Age: 600
uwsgi_1      | X-No-CORS-Reason: https://sendgrid.com/docs/Classroom/Basics/API/cors.html

I can also now query the order to see the address is there:

order.shipping_address                                                                                             
<Address:Rocks>

And that would populate the fields for the form to create the shipment.

Let me know when you are done with my dummy order (or just when you are, delete it, because I put in a real address so you could test the shipping bits, but I'm not comfortable having it on the server.)

hverdonk commented 4 years ago

Yep, I got the email! Feel free to delete the dummy order.

vsoch commented 4 years ago

Great! Before deleting the order, we need to verify that the address fields are filled in - so if you want to create a shipment, then we can verify and close after that.

hverdonk commented 4 years ago

Yep, I see the address.

vsoch commented 4 years ago

Excellent. Thanks for testing!

vsoch commented 4 years ago

okay I just deleted the test order and address, my personal information is safe again!