Magento 2 How to retrieves checkout agreements in GraphQL

In this article, we will show you how to retrieves checkout agreements. The checkoutAgreements query retrieves checkout agreements.

The query will always return an empty array when the Enable Terms and Conditions option is set to No.

So first of all check in Stores > Configuration > Checkout Options > Enable Terms and Conditions and set No to Yes.

Syntax

{
  checkoutAgreements {
    CheckoutAgreement
  }
}

The following query returns enabled checkout agreements.

Request

saveCopyzoom_out_map
{ checkoutAgreements{ agreement_id checkbox_text content content_height is_html mode name } }

Response

saveCopyzoom_out_map
{ "data": { "checkoutAgreements": [ { "agreement_id": 1, "checkbox_text": "I agree to the terms of use", "content": "<h2>What is Lorem Ipsum?</h2>\r\n<p><strong>Lorem Ipsum</strong>&nbsp;is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.</p>", "content_height": null, "is_html": true, "mode": "AUTO", "name": "Terms and Conditions" } ] } }

That's it!!

If you are looking for more GraphQL solutions then check out our another article which is List of GraphQL Queries and Mutations for Magento 2.

I hope this article helps you to find what you were looking for.

Bookmark it for your future reference. Do comment below if you have any other questions on that.

P.S. Do share this article with your team.




Recent Articles
Tags
Newsletter
Chrome Extension
Copyright © 2024 devhooks.in All rights reserved.
Ads OFF toggle_off
wifi_off