0

Now i'm trying for apply coupon to cart and i have followed this link: applyCouponToCart mutation

https://devdocs.magento.com/guides/v2.4/graphql/mutations/apply-coupon.html

But we don't got the mask id when customer is logged in, so how to get mask id for logged in customer otherwise what is other option for logged in customer ?

2
  • As per this documentation rakeshjesadiya.com/masked-id-fro-cart-id-magento-2 the mask id will only be available for guest users. Jul 28, 2022 at 5:15
  • yes i have checked that link but i now i got mask id using by graphql query for logged in customer.
    – user101695
    Jul 28, 2022 at 7:55

1 Answer 1

0

Magento has provided get customer cart id(mask id). So if you want to get current customer mask id run below query and check.

{
  customerCart {
    id
  }
}

And also pass in header customer token.

{
   "Authorization": "Bearer zcnj8wd03u19s5fw1yvkprs23du7tfkh"
}

Let me know if any query.

Updated

Also we face same issue some time as you are facing. For this you need to login into magento side in same browser tab. So, your GraphQl query will found current user data.

THANKS.

5
  • Hello @mohit, i have got the cart id, but after i send request to "applyCouponToCart mutation" it's throw error "The current user cannot perform operations on cart". any help in this ?
    – user101695
    Jul 28, 2022 at 7:54
  • Check this link github.com/magento/magento2/issues/32785 Jul 28, 2022 at 8:59
  • It's not working in 2.4.3 version.
    – user101695
    Jul 28, 2022 at 11:01
  • Can you check my Updated answer Jul 28, 2022 at 14:19
  • Yes, i have checked your answer and it's working for me.
    – user101695
    Jul 29, 2022 at 9:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.