landofcoder / module-customer-membership-graph-ql
Magento 2 客户会员 GraphQL
1.0.1
2023-04-07 09:09 UTC
This package is auto-updated.
Last update: 2024-09-07 12:26:54 UTC
README
``landofcoder/module-customer-membership-graph-ql``
主要功能
Magento 2 客户会员 GraphQL
安装
* = 在生产中请使用 --keep-generated
选项
类型 1: Zip 文件
- 解压 zip 文件到
app/code/Lof
- 通过运行
php bin/magento module:enable Lof_CustomerMembershipGraphQl
启用模块 - 通过运行
php bin/magento setup:upgrade
应用数据库更新* - 通过运行
php bin/magento cache:flush
清除缓存
类型 2: Composer
- 将模块放入 composer 仓库,例如
- 私有仓库
repo.magento.com
- 公共仓库
packagist.org
- 公共 github 仓库作为 vcs
- 私有仓库
- 通过运行
composer config repositories.repo.magento.com composer https://repo.magento.com/
将 composer 仓库添加到配置 - 通过运行
composer require landofcoder/module-customer-membership-graph-ql
安装模块 composer - 通过运行
php bin/magento module:enable Lof_CustomerMembershipGraphQl
启用模块 - 通过运行
php bin/magento setup:upgrade
应用数据库更新* - 通过运行
php bin/magento cache:flush
清除缓存
配置
规格
-
GraphQL 端点
- MembershipProducts
-
GraphQL 端点
- MyMembership
-
GraphQL 端点
- CancelMembership
-
GraphQL 端点
- MembershipTransaction
属性
示例 GraphQL 查询
- 查询会员产品
{
membershipProducts(
filters: {},
pageSize: 10,
currentPage: 1,
sort:{
created_at: DESC
}
){
items{
entity_id
sku
name
status
duration {
record_id
membership_duration
membership_unit
membership_price
membership_order
initialize
}
url_key
customer_group
featured_package
short_description
price
final_price
created_at
store_id
}
total_count
}
}
- 查询我的会员(应在登录客户账户之前)
{
myMembership{
membership_id
group_id
name
duration
price
expiration_date
created_at
status
product_id
item_id
product_options
}
}
- 查询我的会员交易(应在登录客户账户之前)
{
membershipTransaction(
filters: {},
pageSize: 10,
currentPage: 1,
sort:{
created_at: DESC
}
){
items{
transaction_id
name
package
amount
duration
duration_unit
created_at
product_id
item_id
}
total_count
}
}
- 查询 Mutation 取消会员请求(应在登录客户账户之前)
mutation{
cancelMembership(customer_comment: "I want cancel my membership!")
}
- 查询 Mutation 将会员产品添加到购物车(应在登录客户账户之前)
mutation {
addMembershipProductsToCart(
input: {
cart_id: String
cart_items: [{
data : {
sku: String,
quantity: Int
},
duration: String!
}]
}
) {
cart {
items {
... on SimpleCartItem {
product {
name
sku
}
quantity
customizable_options {
label
type
values {
label
value
price {
value
}
}
}
}
}
}
}
}
duration: String!
示例
duration: "1|month"