Creating coupons from the amount in wallet

The main purpose of the wallet is to act as a store containing money for funding wishlist items. For this reason, the wallet can be used to fund both crowdfunded and non-crowdfunded items in the wishlist. Crowdfunded items are funded directly from the wallet by debiting the amount needed from the wallet and crediting it to the crowdfund account for the item, as shown in this article.

Normal wishlist items can also be funded directly from the wallet by debiting the amount needed from the wallet and crediting it to them. However they can also be funded from the wallet by creating coupons from the amount in the wallet to be used when purchasing the wishlist items from the frontend in order to obtain the discount. The caveat with this method is that the plugin allows only administrators to create coupons from the amount in the wallet. This is to keep in line with woocommerce which also allows only administrators to create coupons. This gives the full control of the coupons associated with the wishlist to the administrator. (If the administator chooses, however, he can allow the wishlist owner to create coupons from the frontend via simple developer customization.)

To create a coupon from the amount in the wallet, in the admin edit page for the wishlist, search for the wallet metabox and click on the create coupon button.

This would bring up the modal for creating coupons in which the administrator can set the coupon type, discount amount, as well as specify the wishlist items that the coupon would apply to. Only normal wishist items which have not been fulfilled would be available for selection for the coupon.

When the coupon has been created, the associated amount is debited from the wallet and is no longer available for use on wishlist items via the wallet. A coupon table would be generated at the footer of the wishlist items table showing the details of the existing coupons attached to the wishlist with their usage and other information. Here the coupons can be edited to modify their details or deleted.

Next to the coupon code on the coupons table, a small credit card icon is displayed to denote that the coupon was created from the amount in the wallet. In other words, it is a special coupon. This is to distinguish it from coupons created normally for the wishlist items as the plugin also allows the administator to create coupons for wishlist items in a general sense, not associated with the amount in the wallet.

If a coupon created from the wallet is deleted before it has been used, the coupon amount would be transferred back to the wallet as expected since it was not used. In this way no money in the wallet is lost unintentionally.