The client has a WooCommerce store that sells digital products. These products are related to a Blockchain-based virtual world Decentraland. Since people in this space own NFTs, my client wanted to give access to his digital products based on NFT ownership. On a usual WooCommerce store, to get a digital product you must add it to cart, go through checkout, pay, and then you get access to the download link. But the client wanted his site to check the customer’s MetaMask wallet for the ownership of a particular NFT, and if ownership is confirmed, download access is granted immediately.
I developed a custom WordPress plugin that added the features my client needed. This is what the single product page looks like with the plugin active.
On the admin side, you have the option to specify the Ethereum node that will be used to verify NFT ownership
The NFTs that can be used to restrict access are a custom post type. Custom metadata can be set for an NFT.
Then, in downloadable product settings, you can specify which NFTs are required for download access. I made sure to keep the user interface consistent with WooCommerce’s style.
The plugin has extensive unit tests (PHPUnit) and e2e tests (Puppeteer). It uses Object Oriented PHP. It makes use of
@wordpress/data to handle client side state which you can see on the Single Product page.