定制 mageworx/module-deliverydate-graph-ql 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

mageworx/module-deliverydate-graph-ql

Composer 安装命令:

composer require mageworx/module-deliverydate-graph-ql

包简介

Graph QL Addon for MageWorx Delivery Date Extension

README 文档

README

GraphQL API module for Mageworx Magento 2 Delivery Date extension.

Installation

1) Installation using composer (from packagist)

  • Execute the following command: composer require mageworx/module-deliverydate-graph-ql

2) Copy-to-paste method

  • Download this module and upload it to the app/code/MageWorx/DeliveryDateGraphQl directory (create "DeliveryDateGraphQl" first if missing)

How to use

1. The deliveryDate query returns the information about the selected Delivery Date of the specified cart.

Query attribute is defined below:

cart_id: String! - The unique ID of the cart to query.

By default you can use the following attributes:

day: String     - Delivery day, like 2022-05-11
time: String    - Delivery time, like 00:00_23:59
comment: String - Delivery comment given by a customer

Request:

query ($magentoCartId: String!) {
    deliveryDate(cart_id: $magentoCartId) {
        day
        time
        comment
    }
}

Response:

{
    "data": {
        "deliveryDate": {
            "day": "2022-05-11",
            "time": "14:00_16:00",
            "comment": "Hello GraphQL"
        }
    }
}

Note

We are using next variables in our examples:

{
    "magentoCartId": "{{graphQLCartId}}"
}

where {{graphQLCartId}} is string like VVEmRZMaLRgH1NZ7kkZXWJKIfZiIhbvP (masked quote id).

2. The availableDeliveryDates query returns the information about the all available delivery dates (with time) for the cart.

Query attribute is defined below:

cart_id: String!        - The unique ID of the cart to query.
method: String          - Shipping method code in carriercode_methodcode format. Returns the result for all methods if not specified.
start_day_index: Int    - Offset of days from which the calculation starts. Returns the result from tooday if not specified.
end_day_index: Int      - Number of days to calculate. Returns the result till "Max Delivery Period" if not specified (could be different per Delivery Option configuration).

By default you can use the following attributes:

method: String                  - Shipping method code in carriercode_methodcode format.
day_limits: [DeliveryDayLimit]  - List of available limits for that method and cart

DeliveryDayLimit object:

day_index: Int                      - Index of the day from today (from 0).
date_formatted: String              - Date formatted using format selected in store configuration.
date: String                        - Date in standard Y-m-d format.
extra_charge: ExtraCharge           - Extra charge for that day.
time_limits: [DeliveryTimeLimit]    - Limits by time when available.

DeliveryTimeLimit object:

from: String              - Time from in hh:mm format.
to: String                - Time to in hh:mm format.
extra_charge: ExtraCharge - Extra charge for that time slot. Summed up with a surcharge from the delivery day settings.

ExtraCharge object:

amount: Float           - Amount in selected currency (in cart currency).
formatted: String       - Formatted according selected locale (with currency symbol).
currency_symbol: String - Currency symbol.
currency_code: String   - Currency code.

Request:

query ($magentoCartId: String!) {
    availableDeliveryDates(
        cart_id: $magentoCartId
        method: "flatrate_flatrate"
        start_day_index: 2
        end_day_index: 10
    ) {
        method,
        day_limits {
            day_index
            date_formatted
            date
            extra_charge {
                amount
                formatted
                currency_code
                currency_symbol
            }
            time_limits {
                from
                to
                extra_charge {
                    amount
                    formatted
                    currency_code
                    currency_symbol
                }
            }
        }
    }
}

Response:

{
  "data": {
    "availableDeliveryDates": [
      {
        "method": "flatrate_flatrate",
        "day_limits": [
          {
            "day_index": 5,
            "date_formatted": "14-June-2023",
            "date": "2023-06-14",
            "extra_charge": null,
            "time_limits": [
              {
                "from": "09:00",
                "to": "12:00",
                "extra_charge": {
                  "amount": 0,
                  "formatted": "",
                  "currency_code": "EUR",
                  "currency_symbol": ""
                }
              },
              {
                "from": "11:00",
                "to": "16:00",
                "extra_charge": {
                  "amount": 0,
                  "formatted": "",
                  "currency_code": "EUR",
                  "currency_symbol": ""
                }
              },
              {
                "from": "15:00",
                "to": "20:00",
                "extra_charge": {
                  "amount": 4.5409,
                  "formatted": "€4.54",
                  "currency_code": "EUR",
                  "currency_symbol": ""
                }
              }
            ]
          },
          {
            "day_index": 6,
            "date_formatted": "15-June-2023",
            "date": "2023-06-15",
            "extra_charge": null,
            "time_limits": [
              {
                "from": "09:00",
                "to": "12:00",
                "extra_charge": {
                  "amount": 0,
                  "formatted": "",
                  "currency_code": "EUR",
                  "currency_symbol": ""
                }
              },
              {
                "from": "11:00",
                "to": "16:00",
                "extra_charge": {
                  "amount": 0,
                  "formatted": "",
                  "currency_code": "EUR",
                  "currency_symbol": ""
                }
              },
              {
                "from": "15:00",
                "to": "20:00",
                "extra_charge": {
                  "amount": 4.5409,
                  "formatted": "€4.54",
                  "currency_code": "EUR",
                  "currency_symbol": ""
                }
              }
            ]
          }
        ]
      }
    ]
  }
}

3. The setDeliveryDateOnCart mutation allows you to set delivery date and time to the cart.

Syntax:

mutation: {setDeliveryDateOnCart(input: SetDeliveryDateOnCartInput): Cart}

The SetDeliveryDateOnCartInput object must contain the following attributes:

cart_id: String!                    - The unique ID of a `Cart` object.
delivery_date: DeliveryDateInput!   - Selected delivery date, time (optional) and comment (optional).

The DeliveryDateInput object must contain the following attributes:

day: String!    - A string that identifies a delivery day in standard format Y-m-d.
time: String    - A string that identifies a delivery time diapason in "12:00_23:59" fromat. Must be a valid time.
comment: String - Comment for delivery. Any additional information from customer. Visible to customer by default.

Request:

mutation ($magentoCartId: String!) {
    setDeliveryDateOnCart(
        input: {
            cart_id: $magentoCartId,
            delivery_date: {
                day: "2022-05-11"
                time: "14:00_16:00"
                comment: "Hello GraphQL"
            }
        }
    ) {
        delivery_date {
            day
            time
            comment
        }
    }
}

Response:

{
    "data": {
        "setDeliveryDateOnCart": {
            "delivery_date": {
                "day": "2022-05-11",
                "time": "14:00_16:00",
                "comment": "Hello GraphQL"
            }
        }
    }
}

4. The removeDeliveryDateFromCart mutation allows you to remove selected delivery date and time from the cart (if exists).

Syntax:

mutation: {removeDeliveryDateFromCart(cart_id: String!): Cart}

Request:

mutation ($magentoCartId: String!) {
    removeDeliveryDateFromCart (cart_id: $magentoCartId) {
        delivery_date {
            day
            time
            comment
        }
    }
}

Response:

{
    "data": {
        "removeDeliveryDateFromCart": {
            "delivery_date": {
                "day": "",
                "time": "",
                "comment": ""
            }
        }
    }
}

5. The delivery_date object is also available in the Cart type.

By default you can use the following attributes:

day: String     - Delivery day, like 2022-05-11
time: String    - Delivery time, like 00:00_23:59
comment: String - Delivery comment given by a customer

Request

{
  customerCart {
    id
    items {
      id
      product {
        name
        sku
      }
      quantity
    }
    delivery_date {
        day 
        time
        comment
    }
  }
}

Response

{
    "data": {
        "customerCart": {
            "id": "VVEmRZMaLRgH1NZ7kkZXWJKIfZiIhbvP",
            "items": [
                {
                    "id": "37",
                    "product": {
                        "name": "A",
                        "sku": "A"
                    },
                    "quantity": 1
                }
            ],
            "delivery_date": {
                "day": "2022-05-11",
                "time": "14:00_16:00",
                "comment": "Hello GraphQL"
            }
        }
    }
}

mageworx/module-deliverydate-graph-ql 适用场景与选型建议

mageworx/module-deliverydate-graph-ql 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 435 次下载、GitHub Stars 达 1, 最近一次更新时间为 2022 年 06 月 08 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 mageworx/module-deliverydate-graph-ql 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 mageworx/module-deliverydate-graph-ql 我们能提供哪些服务?
定制开发 / 二次开发

基于 mageworx/module-deliverydate-graph-ql 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 435
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 1
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 1
  • Watchers: 4
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: OSL-3.0
  • 更新时间: 2022-06-08