DavidAJohn / PhotoPortfolio

Personal photo portfolio .NET web application which implements a Blazor and Tailwind CSS user interface with a MongoDb database, and includes integration with Stripe Checkout and Prodigi Print API
0 stars 0 forks source link

Creating Quotes from just a Sku #39

Closed DavidAJohn closed 1 year ago

DavidAJohn commented 1 year ago

The fact that I'd been testing a lot of the Prodigi Print API-related code using the fine art print sku (eg. GLOBAL-FAP-16x24) has inadvertently hidden the fact that some products have required attributes that must be supplied when requesting a quote.

The fine art print doesn't require attributes to get a quote, but the canvases (for example) do need attributes to be specified.

Interestingly, I got the following response when trying to get a canvas quote without supplying the required attributes (which is pretty great and leaves no doubt whatsoever about the problem):

{"outcome": "ValidationFailed",
    "failures": {
        "items[0].attributes": [
            {
                "code": "MissingRequiredAttributes",
                "missingItems": {
                    "attributes": [
                        {
                            "name": "wrap",
                            "validValues": [
                                "White",
                                "MirrorWrap",
                                "ImageWrap",
                                "Black"
                            ]
                        }
                    ]
                },
                "providedValue": null
            }
        ]
    }
}

Ultimately, this means that when a quote request is being constructed, it must get the possible attributes for that sku from the Product Details endpoint first.

I don't believe the price varies between attribute options, so just to initially get this working we could just pick the first option and supply that. In the case of the eco canvas that would be {"wrap" : "white"}.

Eventually though, the PhotoDetails page and the Basket model will need to accomodate these attributes, allow customers to choose them and then supply them to the Prodigi Print API when requesting quotes and creating orders.

DavidAJohn commented 1 year ago

It is now possible to get quotes with or without required attributes.

I've created a separate issue for updating the PhotoDetails page and the Basket model: #40