Download the PHP package cryptom2/magento-nftloyalty without Composer
On this page you can find all versions of the php package cryptom2/magento-nftloyalty. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cryptom2/magento-nftloyalty
More information about cryptom2/magento-nftloyalty
Files in cryptom2/magento-nftloyalty
Package magento-nftloyalty
Short Description Magento 2 NFT Loyalty extension that allows to use NFT token as 'Discount Card' for implementing NFT Loyalty Programs.
License MIT
Informations about the package magento-nftloyalty
Crypto NftLoyalty Magento 2 Extension
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
balanceOf
on 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.
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
balanceOf
greater 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