woocommerce / woocommerce-ios

WooCommerce iOS app
https://www.woocommerce.com/mobile
GNU General Public License v2.0
299 stars 110 forks source link

Shipping Labels: API for getting the origin address from the last shipping label #5039

Open pmusolino opened 2 years ago

pmusolino commented 2 years ago

As discussed here C026HH75ECA/p1632316480025600 it would be great to have a way for obtaining the last origin address used for creating a Shipping Label (WCShip plugin).

Currently, the behavior is different between mobile (iOS/Android) and the web. On the web, after having purchased a Shipping Label, the "Ship From" address will be the last used for purchasing a shipping label. On mobile, the address that will populate the "Ship From" form will be always the address of the store, because we don't have an API for accessing that information.

I also noticed that after buying a shipping label from mobile, when I try to create a new shipping label from the web, the "Ship From" address will be the one of the last shipping label purchased (also if it happened from mobile), so I imagine that the origin address is stored somewhere in the DB. Schermata 2021-09-22 alle 17 11 22

What do we want to accomplish?

The changes I make on the "Ship From" address aren't persisting between labels. We need an API for fetching the last origin address used in a Shipping Label. Ideally, it will return the address of the store if there are no existing shipping labels.

It would be great to follow this JSON format for the address (that we already use in the app, and it's the same format currently used in Orders, ShippingLabels, etc...):

"data": {
            "first_name": "Johnny",
            "last_name": "Appleseed",
            "company": "",
            "address_1": "234 70th Street",
            "address_2": "",
            "city": "Niagara Falls",
            "state": "NY",
            "postcode": "14304",
            "country": "US",
            "email": "scrambled@scrambled.com",
            "phone": "333-333-3333"
}
joshbetz commented 2 years ago

I think the API that the web is using is api.woocommerce.com. Do we currently have any integrations there in the app?