cryptom2/magento-nftloyalty
Composer 安装命令:
composer require cryptom2/magento-nftloyalty
包简介
Magento 2 NFT Loyalty extension that allows to use NFT token as 'Discount Card' for implementing NFT Loyalty Programs.
README 文档
README
Magento 2 NFT Loyalty Extension Allows to use NFT token as 'Discount Card' for implementing NFT Loyalty Programs.
Description
Extension adds new condition for Magento 2 Cart Rules functional and checks if customer has tokens of specified NFTs in wallet.
If NFT tokens are presented in wallet - it applies discount follow rules that are set in Magento Cart Rules.
Extension allows to implement discount programs, partnership program, NFT loyalty programs between magento stores and web3 projects.
For frontend actions module uses Metamask and web3.js, for backend checks - modified web3.php library.
How It Works
Customer can apply NFT on cart page and on checkout page too.
- Customer connect own wallet to website and press
Apply NFT. - Customer wallet address is sent to backend and saving to Quote table.
- After saving, Magento gets all NFTS from NFT table and check whether customer has any or several from that NFTs by calling
balanceOfon NFTs smart contract - If customer has NFTs from NFT table, found NFT are saved in separate table
- Magento recalculate totals (run collectTotals after applying NFT)
- During collecting totals, Magento runs sales rule total that runs NFT rule and apply Cart Rule if it fits
- Magento updates Summary (totals) sections on frontend for outputting discount for customer
Installation
Add PHP Web3 Repository
PHP Web3 library uses old version of phpseclib (v2), but magento requires version 3. It was changed in web3 fork thus you need to add custom repository for web3.php.
"web3p/web3.php": { "type": "git", "url": "git@github.com:torys877/web3.php.git" }
Composer Installation
composer require cryptom2/magento-nftloyalty:v1.0.0
Magento Run
php bin/magento setup:upgrade
Hardhat install for testing
Hardhat allows you to run local ethereum network, deploy demo NFT and test module locally.
Go To:
{project_folder}/vendor/cryptom2/magento-nftloyalty/hardhatnft
Run:
npm install --save-dev hardhat
npx hardhat node
npx hardhat run --network localhost ./scripts/deploy.ts
After that commands you should see NFT token address for demo test and hardhat default account, that can be integrated in Metamask.
Features
Menu Under Marketing Section
Adding New NFT
NFT Name- will be used in Cart Rules in admin area for selection NFT (later, for output on frontend to show which NFT was applied exactly)NFT Contract Abi- not used now, will be used later if NFT needs some custom functionalNFT Symbol- will be used later or instead of NFT NameNFT Address- address of NFT, Magento checks customer NFT balance using this NFT address
Configuration
Enabled- enable/disable functionalRPC Endpoint- endpointNFT Smart Contract ABI- Default JSON ABI for NFT smartcontract. Now there is using only 1 functionbalanceOf
Apply NFT Section on Cart Page
Apply NFT Section on Checkout Page
Adding Sales Rule With NFT Condition
TODO
Now the extension has base functional and checks only if customer has or no NFT in wallet. But it has much more potential in future.
Here are several TODOs that are going to be implemented later:
- add checking NFT tokens amount and apply discount based on how many NFTs customer has (now it checks only
balanceOfgreater than zero or no) - output NFT name, rule name or NFT symbol on checkout and cart pages, to show what NFT was applied for discount
- send customer wallet and some data as signed message from frontend to backend during applying NFT (for security)
- mint NFT for customer depending on some conditions (order grand total or amount of purchases in the store)
- output customer wallets(accounts) to choose which should be assigned to website or which should be used for NFT applying.
- implement some kind of NFT interface to keep Discount Rules inside NFTs smart contract and apply them in Magento
- feel free to fork and fix/implement anything if you are interested
Author
Ihor Oleksiienko
License
Magento NFT Loyalty extension for Magento 2 is licensed under the MIT License - see the LICENSE file for details
cryptom2/magento-nftloyalty 适用场景与选型建议
cryptom2/magento-nftloyalty 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3 次下载、GitHub Stars 达 5, 最近一次更新时间为 2023 年 03 月 28 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 cryptom2/magento-nftloyalty 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 cryptom2/magento-nftloyalty 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 3
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 23
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2023-03-28








