Lab - Postman Quote Workflow
Lab - Postman Quote Workflow
Lab - Postman Quote Workflow
In this lab, you’ll explore the common storefront tasks involved with managing and submitting quotes. This will also give you an opportunity to observe the impact that different user roles have on GraphQL results.
The lab will involve logging into your storefront as a company user to place an order from a quote. The following minimal settings are required in the B2B Edition section of your control panel:
As a reminder, in previous labs you should have set up these collection variables:
admin_emailadmin_passwordjunior_emailjunior_passwordMake sure these variables are set with valid credentials values. You’ll need the “Admin Login” and “Junior Login” requests that you previously created.
These tests verify not only that currency information was returned in the proper format, but also that the currency identified as the channel’s default is specifically present.
There are quite a lot of values being captured in Postman collection variables here, but all will be needed when submitting a quote. This script ensures that the values matching the storefront’s default currency are automatically captured.
In order to submit a quote request for specific products from your storefront, you’ll need catalog details like product and variant IDs, as well as product prices. In this section, you’ll utilize the productsSearch query to capture these details. Automation utilizing Postman scripts will assist in translating the appropriate values from the product data into the eventual quote request.
You’ll perform this and subsequent requests from the context of your Junior Buyer user, as this role has permission to submit quotes.
b2b_logged_in_email variable on your environment reflects the Junior Buyer email address.b2b_logged_in_company_id variable is not set in your environment, or the company ID doesn’t match your Junior Buyer user, re-run the “User Company” request.Now that you’ve authenticated as a Junior Buyer, let’s set up the request to fetch product details. For the workflow you’ll be setting up, you’ll choose two products from your store catalog to be part of the quote.
/manage/products/edit/{product-id}.If possible, include a product with variants as one of your IDs, as you’ll be able to observe the effects of the quote process with such a product.
<Product 1 ID> and <Product 2 ID> with the IDs of your chosen products. For example, [13, 27].Observe in the script that the numberOfProducts variable controls the test that verifies the proper number of products were returned (2). The productQty variable will also be used as a multiplier for product prices; we’ll eventually be including 10 of each product in the quote request.
The request submitting the quote will be specifically configured for two products and a quantity of 10 for each, but if you choose to change the details of that request, you can easily update the above variables to make sure productsSearch captures the right info.
The script tests that the values you intend to capture are present on each product and compiles that data into a new array. Notice that some values are captured from the product record, while others are captured from the product’s first available variant.
The final portion of the post-response script captures the required values for each product in collection variables - for example, product1_id, product1_price, etc. The full expected price of the initial quote request (based on a quantity of 10 of each product) is also captured.
The product details you’ve captured can now be fed directly into the request to submit the quote.
Note that the collection variables you’ve captured with your previous requests are being used to populate the appropriate GraphQL variables related to currency, product details and pricing.
In this request, we’re providing a value for channelId, which is not required if your store does not support multiple storefronts. If multiple storefronts are supported, however, this field is necessary even if one storefront is designated as default.
The ID and UUID of the newly created quote, as well as its “created at” timestamp, are captured in collection variables to automatically tie subsequent requests to the most recently created quote.
quote_id and quote_created_at variables are set on your collection.You should also be able to see your new quote in the B2B Edition admin, or in the storefront while logged in as one of the company’s users.
At this step, you may choose to edit the quote in the B2B Edition admin - for example, to set a discount on one or more items in the quote. (Be sure to “Preview” and then “Submit” the quote.) A typical workflow would involve a sales rep making such edits before the next steps in the quote process.
While editing the quote, also try including a message for the buyer.
Now you’ll make a storefront request to fetch all the quotes belonging to your company.
Like in previous requests, the arguments and variables here are designed to easily facilitate pagination once the company has multiple quotes. The “-createdAt” value being passed in for orderBy ensures the quotes will be sorted in descending order by the creation date.
As you’re sorting by creation date, the quote you previously created should be first in the results.
If you edited the quote from the perspective of a sales rep, observe the effects in the trackingHistory field and the various price fields that reflect any new discounts.
Note that you’re passing in the collection variables that previously captured the quote ID and “created at” timestamp, meaning you’ll automatically be exporting a PDF for the most recently created quote. Feel free to manually change these values in the collection.
The most critical step of the quoting process from the storefront perspective is actually placing an order from the quote details. Let’s practice generating the appropriate URL that will allow a storefront user to complete this process in the BigCommerce checkout.
Your request is fully configured. However, recall that you most recently used the “Junior Buyer Login” request to generate the GraphQL credentials you’ve been using in the quote creation process, and users with the Junior Buyer role do not have permission to place an order from a quote. Presuming your user’s role hasn’t been changed, you should be able to observe that the “Get Quote Checkout” requests fails with your current authentication.
Generating the checkout URL successfully should be as easy as re-authenticating as a user with sufficient permissions.
checkoutUrl from the response and enter it in a browser to verify that the checkout is initiated.The invoice workflow you’ll examine in the next lab is usually relevant for orders that have been paid with credit, so using the Purchase Order payment method will make sure you have an order that makes sense for that workflow.
Try out implementing a “Get Quote” request to fetch the details of a single quote using the quote GraphQL query. Configure the request to utilize your quote_id and quote_created_at collection variables to automatically fetch the most recently created quote.