Promocodes not working

Forum
Last Post
Threads / Messages

Niddrie

Member
Member
Joined
Apr 20, 2012
Messages
2
Points
1
Location
USA
Mysidian Dollar
24
Hi guys! I recently downloaded and set up version 1.3.6. I can't get promo codes to work. I haven't changed anything in the codes. When I enter the promocode it creates the adoptable but doesn't assign it to my account and instead assigns it to account #0. I have it set through Amin CP so that all users should be able to enter the promocode and receive an adopt, but it doesn't seem to matter. When I check the database it says user #0 and I can't seem to set it to all users in the database. (attached pictures below)

Screen Shot 2023-01-19 at 3.59.10 PM.png
In the database it is set to user #0 and not All Users, when the promocode is entered it assigns the new adopt to User #0.
Screen Shot 2023-01-19 at 4.03.38 PM.png
In Admin Control Panel it says ALL Users
 
Hi guys! I recently downloaded and set up version 1.3.6. I can't get promo codes to work. I haven't changed anything in the codes. When I enter the promocode it creates the adoptable but doesn't assign it to my account and instead assigns it to account #0. I have it set through Amin CP so that all users should be able to enter the promocode and receive an adopt, but it doesn't seem to matter. When I check the database it says user #0 and I can't seem to set it to all users in the database. (attached pictures below)

View attachment 510
In the database it is set to user #0 and not All Users, when the promocode is entered it assigns the new adopt to User #0.
View attachment 511
In Admin Control Panel it says ALL Users
That's the way the code is set up, where 0 means anyone can claim. So when a user uses the code, it gives them the adopt still but the promo is 0. The promo uid changes to a uid number if the code is specific to a user, otherwise 0.

So the adopt would now belong to that user that used the code, and it can be traded etc. If you want it to be tied to the user after claimed you need to create a code that looks at a users adopts and changes the adopt to be bound to the user uid.
 
The problem I am running into is that when the user uses the code, it does not give them the adopt. The adopt is created but is given to user # 0 instead. So the promocode successfully creates the adoptable but assigns it to the wrong account # (which happens to be account #0) instead of the account # that claimed the code. Hopefully that makes sense, I'm not a coder and can't figure it out on my own :)
 
The problem I am running into is that when the user uses the code, it does not give them the adopt. The adopt is created but is given to user # 0 instead. So the promocode successfully creates the adoptable but assigns it to the wrong account # (which happens to be account #0) instead of the account # that claimed the code. Hopefully that makes sense, I'm not a coder and can't figure it out on my own :)
If you like, you can join the Mysidia Discord server and message me on Discord. I'm Micolai#8352 https://discord.gg/NKaB3whu I'm faster to reply on there since I get alerts. I can help you out the best I can with things. You may be needing to look in your file that holds the db update code that creates the adopts for the user when they use promo codes. If you message me on Discord I can try to help tackle the issue when I'm free.
 
I'm also having this issue when it's set to a specific user it works fine, but when it's all users, it just goes through the motions (it tells the user it was processed and given the pet but when they go to their adoptables, it's not there)

I tried to join the discord to see if a solution was posted but the link is expired
 
I'm also having this issue when it's set to a specific user it works fine, but when it's all users, it just goes through the motions (it tells the user it was processed and given the pet but when they go to their adoptables, it's not there)

I tried to join the discord to see if a solution was posted but the link is expired
Try this link:

https://discord.gg/88rN5cPK
 
For anyone's reference, we managed to fix it using a quick and dirty method... definitely not the cleanest so hopefully it can get a bug fix in the actual script lol.

The problem: Adopt promocodes that are set for everyone (user field in DB is 0) can be redeemed by any user as intended but the owner field gets set as 0, and not actually the user's ID. This means they technically don't own the pet.

In model/domainmodel/promocode.php, find public function execute and replace it with this:

PHP:
public function execute(){
        $mysidia = Registry::get("mysidia");
        // This method will execute the promocode and give users their desired adoptables or items, need to be used after validation is completed     
        switch($this->type){
            case "Adopt":
                // The user will receive an adoptable from the promocode now.
                $adopt = new Adoptable($this->reward);

                if ($this->getUser() == 0){
                    $adopt->makeOwnedAdopt($mysidia->user->getID());
                }

                else{
                    $adopt->makeOwnedAdopt($this->user);
                }
                
                $this->usePromo();
                return $adopt->getType();
            case "Item":
                // The user will receive an item from the promocode now.           
                $item = new OwnedItem($this->reward, $this->user);
                if($item->isOverCap(1)) throw new NoPermissionException("It appears that you cannot add one more of item {$item->getItemname()} to your inventory, its quantity has already exceeded the upper limit.");               
                $item->add(1, $this->user);
                $this->usePromo();
                return $item->getItemname();
            case "Page":
                $this->usePromo();
                break;
            default:
                throw new PromocodeException("type");     
        }
    }

This will check if the 'user' field is set to 0 (aka no specific user is assigned to it) and if so it will get the UID of the user trying to use the code to give them the pet. I'm sure there's a better way but for now this works!
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,113
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top