How to Managing Guest Cart Billing address (V1/guest-carts/:cartId/billing-address) by REST API Magento 2?

You can manage the Guest cart billing address for the current quote of the guest customers in Magento 2 with the help of REST API.

You can use the given Rest URL to set and get the Billing address of the Guest cart.

/V1/guest-carts/:cartId/billing-address

If you want to assign a billing address to a specific cart, You can use the POST method to set the billing address on the current guest cart,

I hope you have available Guest cart token to use in our API request.

  • Request URL:  <URL>/V1/guest-carts/:cartId/billing-address

(Example: https://magento.test.com/rest/V1/guest-carts/tYqIEtiDdGx2Jw9MAyzR7FP9tx6ruD4b/billing-address)

  • Action: POST
  • Request Payload:
{
    "address": {
        "region": "",
        "country_id": "GB",
        "street": [
            "West road"
        ],
        "postcode": "W1S 1LA",
        "city": "London",
        "firstname": "Rakesh",
        "lastname": "Patel",
        "email": "rakesh@jesadiya.com",
        "telephone": "04422531111"
    }
}

Response: Quote Billing Address ID (101)

In the above Request URL, If you use the Action method as GET, you can fetch the available guest cart billing address.

Thank you.

How to get customer id from API header bearer token Magento 2?

You can fetch the customer ID from the Web API Header Authorization Token in Magento 2.

At the development time of a custom module, you are required to fetch the customer ID from the Bearer token passed in the Header.

You can just follow the given code snippet to fetch the customer ID from the current payload. Continue reading “How to get customer id from API header bearer token Magento 2?”

How to use insertFromSelect query in database Magento 2 with best practice?

You can use INSERT IGNORE INTO mysql query with the help of insertFromSelect() method in Magento 2 with use of magento best standard in your module.

Lets we have a query that use the insertFromSelect method to run a query.

Raw SQL Query to add an entry to the small_image attribute from the image attribute value. Continue reading “How to use insertFromSelect query in database Magento 2 with best practice?”