cancel
Showing results for 
Search instead for 
Did you mean: 

Magento 2.3 Gift card rest API for add to cart

Magento 2.3 Gift card rest API for add to cart

 

I have checked https://devdocs.magento.com/swagger/index_23.html#/giftCardAccountGiftCardAccountManagementV1

 for api but it is not clear where to pass recipient name,email.message details.

Can someone tell me about gift card purchase flow in magento 2.3 ?

6 REPLIES 6

Re: Magento 2.3 Gift card rest API for add to cart

@sidharth_kothar 

 

Here you can go to know workflow:

 

https://docs.magento.com/user-guide/catalog/product-gift-card-workflow.html

 

Apart from that in shared swagger API's defined for guest and customer. It is same as add product to cart and you can add gift into cart using below shared:

https://www.mageworx.com/blog/magento-2-gift-cards-available-rest-api-requests/

Manish Mittal
https://www.manishmittal.com/

Re: Magento 2.3 Gift card rest API for add to cart

Thanks @Manish Mittal for response but I already checked these document and not that useful.

I have checked magento 2.3 swagger api  but what mention here 

https://www.mageworx.com/blog/magento-2-gift-cards-available-rest-api-requests/

is not present in magento 2.3 swagger so 

Re: Magento 2.3 Gift card rest API for add to cart

Re: Magento 2.3 Gift card rest API for add to cart

This is the swagger

https://devdocs.magento.com/swagger/index_23.html#/giftCardAccountGiftCardAccountManagementV1/giftCa...

 

json request mention there is 

{
  "giftCardAccountData": {
    "gift_cards": [
      "string"
    ],
    "gift_cards_amount": 0,
    "base_gift_cards_amount": 0,
    "gift_cards_amount_used": 0,
    "base_gift_cards_amount_used": 0,
    "extension_attributes": {}
  }
}

which is not clear and not mentioned where to pass recipient details

 

 

Re: Magento 2.3 Gift card rest API for add to cart

Hi @sidharth_kothar 

To add giftcard with cart, please use following API:

URL : /V1/carts/{cartId}/giftCards
Method : PUT
Token: Customer Token
Request:

{
  "giftCardAccountData": {
    "gift_cards": [
      "string"
    ],
    "gift_cards_amount": 0,
    "base_gift_cards_amount": 0,
    "gift_cards_amount_used": 0,
    "base_gift_cards_amount_used": 0,
    "extension_attributes": {}
  }
}

This is the only way to apply giftcard coupon with cart for customer.

For adding a product to cart with custom options like receipent email or message, you need to call below url:
url : /V1/carts/mine/items
Method: post
Token: Customer
Request :

{
    "cart_item": {
        "quote_id": "9",
        "sku": "24-MB01",
        "qty": 1,
        "productOption":{
            "extensionAttributes":{
                "customOptions":[
                    {
                        "optionId":"1",
                        "optionValue":"2"
                    }
                    ]
            }
        }
    }
}


If issue resolve, Please click on 'Kudos' & Accept as Solution!

 

Problem solved? Click Accept as Solution!

Re: Magento 2.3 Gift card rest API for add to cart

@Bhanu Periwal 

 

Can you send example with values because as far as I know extension attributes value are fixes so how to pass recipient email,message ?

 

Also this json is confusing

{
  "giftCardAccountData": {
    "gift_cards": [
      "string"
    ],
    "gift_cards_amount": 0,
    "base_gift_cards_amount": 0,
    "gift_cards_amount_used": 0,
    "base_gift_cards_amount_used": 0,
    "extension_attributes": {}
  }
}

Where from to get these details ?
do I need to call any api to get gift_cards code and pass here ?
what is base_gift_cards_amount,base_gift_cards_amount_used ? and other fields
Because in magento backend configuration there is no option to set these so where from to
to get these