Soomla.Store.UpgradeVG.canBuy C# (CSharp) Méthode

canBuy() protected méthode

Determines if the user is in a state that allows him/her to buy an UpgradeVG This method enforces allowing/rejecting of upgrades here so users won't buy them when they are not supposed to. If you want to give your users free upgrades, use the give function.
protected canBuy ( ) : bool
Résultat bool
		protected override bool canBuy() {
			VirtualGood good = null;
			try {
				good = (VirtualGood) StoreInfo.GetItemByItemId(GoodItemId);
			} catch (VirtualItemNotFoundException) {
				SoomlaUtils.LogError(TAG, "VirtualGood with itemId: " + GoodItemId +
				                     " doesn't exist! Returning NO (can't buy).");
				return false;
			}
			
			UpgradeVG upgradeVG = VirtualGoodsStorage.GetCurrentUpgrade(good);

			return ((upgradeVG == null && string.IsNullOrEmpty(PrevItemId)) ||
			        (upgradeVG != null && ((upgradeVG.NextItemId == this.ItemId) ||
			                       (upgradeVG.PrevItemId == this.ItemId))))
				&& base.canBuy();
		}