Skip to main content

MageMe HidePrice Pro Magento 2 Module | GraphQL

The HidePrice Pro GraphQL API provides a powerful interface for developers to interact with the HidePrice Pro module in a Magento 2 environment using GraphQL. This documentation outlines how to utilize the GraphQL endpoints to manage and retrieve hide price request data effectively.

Overview

GraphQL is a query language for APIs that offers a more efficient and powerful alternative to REST. It allows clients to request exactly the data they need, making it faster and more flexible.

GraphQL API Endpoints

1. Retrieve Request by ID

  • Operation: hidepriceRequest
  • Description: Fetches detailed information about a specific hide price request.
  • Arguments:
    • request_id (Int!): The ID of the request to retrieve.
  • Returns: HidePriceRequest object including specified fields.

Example Query:

query {
hidepriceRequest(request_id: 123) {
request_id
increment_id
customer_email
customer_firstname
customer_lastname
message
created_at
product {
product_id
product_name
product_sku
}
}
}

2. List Requests with Filters

  • Operation: hidepriceRequests
  • Description: Retrieves a list of hide price requests optionally filtered by certain criteria.
  • Arguments:
    • filter (String): JSON string for key:value pairs to filter requests.
  • Returns: An object containing an array of hide price request objects that match the criteria and a count.

Example Query:

query {
hidepriceRequests(filter: "{\"customer_email\": \"customer@example.com\"}") {
items {
request_id
customer_email
is_read
created_at
product {
product_id
product_sku
}
}
count
}
}

3. Submit New Request

  • Operation: hidepriceRequestSubmit (Mutation)
  • Description: Submits a new hide price request.
  • Arguments:
    • email (String!): Customer email address.
    • lastname (String): Customer last name.
    • firstname (String): Customer first name.
    • phone (String): Customer phone number.
    • message (String): Customer message.
    • attachment (String): Attachment file reference.
    • custom_field_1 (String): Custom field 1 value.
    • custom_field_2 (String): Custom field 2 value.
    • custom_field_3 (String): Custom field 3 value.
    • product_id (Int!): ID of the product being requested.
    • product_sku (String): SKU of the product.
    • product_name (String): Name of the product.
    • product_options (String): Selected product options.
  • Returns: HidePriceRequest object with details of the submitted request.

Example Mutation:

mutation {
hidepriceRequestSubmit(
email: "customer@example.com",
firstname: "John",
lastname: "Doe",
phone: "+1234567890",
message: "I would like to know the price of this product.",
product_id: 456,
product_sku: "SKU-456",
product_name: "Example Product"
) {
request_id
increment_id
customer_email
created_at
}
}

4. Upload File for Request

  • Operation: hidepriceRequestUpload (Mutation)
  • Description: Uploads a file to be attached to a hide price request.
  • Arguments:
    • filename (String!): Name of the file.
    • content (String!): Base64 encoded content of the file.
    • mimeType (String): MIME type of the file.
  • Returns: String value representing the file reference to be used in request submission.

Example Mutation:

mutation {
hidepriceRequestUpload(
filename: "product_specs.pdf",
content: "base64EncodedFileContentHere",
mimeType: "application/pdf"
)
}

Data Types

Hide Price Request (HidePriceRequest):

  • Represents a request with various fields like request_id, increment_id, customer_email, etc.
  • Contains a subfield product which is a HidePriceRequestedProduct object with product details.

Product (HidePriceRequestedProduct):

  • Represents the product details associated with a hide price request.
  • Includes fields such as product_id, product_sku, product_name, and product options.

Hide Price Requests (HidePriceRequests):

  • A wrapper type that includes an array of HidePriceRequest objects and a count of total items returned.

Permissions

To use these endpoints, the API consumer must have the appropriate permissions set up in Magento under MageMe_HidePricePro::manage_requests.

Conclusion

The HidePrice Pro GraphQL API provides comprehensive access to hide price request functionalities, allowing developers to perform advanced operations like retrieving, filtering, submitting, and managing requests directly through GraphQL. This can be integrated into frontend applications to enhance user interaction with the hide price feature, leveraging the full capabilities of Magento 2 and HidePrice Pro.