woocommerce / woocommerce-ios

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

Hide shipping address for virtual products #705

Closed nbradbury closed 4 years ago

nbradbury commented 5 years ago

Right now we show the shipping address even for virtual products. We should hide the shipping address in this situation.

Related Android issue

mindgraffiti commented 5 years ago

@kyleaparker I am not sure what the expected behavior is here. On iOS, if the Shipping Address is blank, "No address specified." is the message displayed underneath the Shipping details heading. It looks like this:

Android has a related task filed to show the same thing: https://github.com/woocommerce/woocommerce-android/issues/298.

If you mean "don't display the Customer Info section at all for digital / download-only orders", there isn't an explicit way to identify those. We don't have any properties that let us know that the order was for a virtual product.

cc: @nbradbury, in case I missed something

This is what an order object response looks like for a digital download order:

{
    "id": 2198,
    "parent_id": 0,
    "number": "2198",
    "order_key": "wc_order_XDNP86jchb3oL",
    "created_via": "checkout",
    "version": "3.5.5",
    "status": "completed",
    "currency": "USD",
    "date_created": "2019-03-14T15:25:50",
    "date_created_gmt": "2019-03-14T19:25:50",
    "date_modified": "2019-03-14T15:25:53",
    "date_modified_gmt": "2019-03-14T19:25:53",
    "discount_total": "0.00",
    "discount_tax": "0.00",
    "shipping_total": "0.00",
    "shipping_tax": "0.00",
    "cart_tax": "1.78",
    "total": "21.78",
    "total_tax": "1.78",
    "prices_include_tax": false,
    "customer_id": 12,
    "customer_ip_address": "50.27.182.89",
    "customer_user_agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Safari/537.36",
    "customer_note": "",
    "billing": {
        "first_name": "ArtDesign",
        "last_name": "Love",
        "company": "Cooper Hewitt Smithsonian Design Museum",
        "address_1": "2 E 91st St",
        "address_2": "",
        "city": "New York",
        "state": "NY",
        "postcode": "10128",
        "country": "US",
        "email": "thuy.copeland@gmail.com",
        "phone": "9138675309"
    },
    "shipping": {
        "first_name": "",
        "last_name": "",
        "company": "",
        "address_1": "",
        "address_2": "",
        "city": "",
        "state": "",
        "postcode": "",
        "country": ""
    },
    "payment_method": "stripe",
    "payment_method_title": "Credit Card (Stripe)",
    "transaction_id": "ch_1EDzBcAaDnQynKB0DkZgCEgw",
    "date_paid": "2019-03-14T15:25:53",
    "date_paid_gmt": "2019-03-14T19:25:53",
    "date_completed": "2019-03-14T15:25:53",
    "date_completed_gmt": "2019-03-14T19:25:53",
    "cart_hash": "d8a896e2f33360fe4c36f40fe83af6b5",
    "meta_data": [
        {
            "id": 60290,
            "key": "_stripe_source_id",
            "value": "src_1EDzBaAaDnQynKB0zOCfuY5w"
        },
        {
            "id": 60291,
            "key": "_stripe_charge_captured",
            "value": "yes"
        },
        {
            "id": 60292,
            "key": "_stripe_fee",
            "value": "0.93"
        },
        {
            "id": 60293,
            "key": "_stripe_net",
            "value": "20.85"
        },
        {
            "id": 60294,
            "key": "_stripe_currency",
            "value": "USD"
        }
    ],
    "line_items": [
        {
            "id": 1518,
            "name": "Cartoons Catalog (Downloadable File)",
            "product_id": 20,
            "variation_id": 0,
            "quantity": 1,
            "tax_class": "",
            "subtotal": "20.00",
            "subtotal_tax": "1.78",
            "total": "20.00",
            "total_tax": "1.78",
            "taxes": [
                {
                    "id": 1,
                    "total": "1.775",
                    "subtotal": "1.775"
                }
            ],
            "meta_data": [],
            "sku": "",
            "price": 20
        }
    ],
    "tax_lines": [
        {
            "id": 1519,
            "rate_code": "US-NY-NY TAX-1",
            "rate_id": 1,
            "label": "NY Tax",
            "compound": false,
            "tax_total": "1.78",
            "shipping_tax_total": "0.00",
            "meta_data": []
        }
    ],
    "shipping_lines": [],
    "fee_lines": [],
    "coupon_lines": [],
    "refunds": [],
    "_links": {
        "self": []
    }
}
kyleaparker commented 5 years ago

If no shipping address was entered can we assume the order didn't contain any items that need to be shipped?

bummytime commented 5 years ago

If no shipping address was entered can we assume the order didn't contain any items that need to be shipped?

@kyleaparker unfortunately I don't think we can make that assumption. Testing things out on my (fairly) stock WC store, I created 2 separate orders for: 1) a virtual product and 2) a product that "ships". In both cases the shipping address defaulted to empty and only the billing address was filled in.

Napkin 129 03-18-19, 1 41 30 PM

Additionally, I inspected the information returned to the app via Orders API and the line item data does not denote if a given product is "virtual" or not. For that, we would need to make a second call to the products API.

/cc @nbradbury in case I am missing something obvious here. 😄

kyleaparker commented 5 years ago

@kyleaparker unfortunately I don't think we can make that assumption. Testing things out on my (fairly) stock WC store, I created 2 separate orders for: 1) a virtual product and 2) a product that "ships". In both cases the shipping address defaulted to empty and only the billing address was filled in.

Makes sense, I'm ok with leaving what we have now where we simply say "No address specified".

Would it eventually be the possibility to check the products in the order to see if they are virtual products, and from there we know if any of the products require shipping?

bummytime commented 5 years ago

Would it eventually be the possibility to check the products in the order to see if they are virtual products, and from there we know if any of the products require shipping?

@kyleaparker Sure, we could do that. If we have the products cached locally, perhaps we do a quick "shippable product check" and they adjust the UI from there.

I'll leave this issue open so we don't lose this. 😄

mindgraffiti commented 4 years ago

@jaclync @pmusolino are spearheading the Products features. Can one of you verify if this feature request is possible to implement now?