PDA

View Full Version : Mys 1.3.4 User Shops


Dinocanid
12-28-2017, 02:11 PM
Requirements: Database math (https://dinoscripts.wordpress.com/mods/db_math_mod/) | Original Owner (http://www.mysidiaadoptables.com/forum/showthread.php?t=4826) | Secondary Currency (http://www.mysidiaadoptables.com/forum/showthread.php?t=5460)
Description: This addon allows users to create their own shops that they can use to sell their pets and items to other users. The shop styling is the same from Kyttias's Item Shop mods (http://www.mysidiaadoptables.com/forum/showthread.php?t=4741), but you don't need that mod for this one to work.
(At the moment, this tutorial only covers pets)
12/30/17: Fixed a bug where you couldn't edit your own shop
-Step 1-
Create a new table in the database called (prefix)_adopt_stock with these settings:
http://www.clipular.com/c/5097920373456896.png?k=f28yznyAdvQhL57UcjpXFk3InNg

Next, create another table called (prefix)_user_shops with these settings:

http://www.clipular.com/c/5680560671555584.png?k=u1Gio8V-KazECCK6qIMNXrDFi74

-Step 2-
Download and unzip the file in the attachments, then place them where they need to go.

-Step 3-
You want a way for users to put their pets up for sale. This is how I set it up on my site in myadoptsview.php: Pastebin link (https://pastebin.com/Z85nC4aU)
Now I can use {$sale_manage} to display all the information I need.
That should be it! Let me know if there are any bugs in it, since I'm not always good at spotting them all.

-Q&A-
Q: Why don't you use mysidia's form builder?
A: Honestly, I just don't like using it. To me, using an html form allows for more customization and flexability

Q: The styling looks a weird!
A: I use Bootstrap 4 on my site, so the styling might look weird if you don't have it installed. Luckily, the tables and forms can easily be re-styled.

Q: What is "tax" for?
A: That was meant to be a feature where users could apply a tax to their shops, but I ended up not including it.

Abronsyth
12-28-2017, 09:40 PM
Ooh! Nice!! Absolutely going to play with this tomorrow, thank you so much for sharing!

Abronsyth
12-29-2017, 10:34 PM
I'm about to go to bed so I am keeping this short- I'm having an issue when trying to edit my shop where it is not recognizing that my uid is the shop_manager id, so it's telling me I don't own the shop.

Dinocanid
12-30-2017, 07:43 AM
I'm about to go to bed so I am keeping this short- I'm having an issue when trying to edit my shop where it is not recognizing that my uid is the shop_manager id, so it's telling me I don't own the shop.

I think it's because I forgot to add these variables to the "else" statement in public function edit() of shopcpview.php:
$manager_id = $shop->manager_id;
$uid = $mysidia->user->uid;
I re-uploaded the script in case that wasn't what was missing, but I think that's what I did.

EDIT: There's also a bug where premium currency would still subtract and proceed with giving you the pet, even if you don't have enough. Add this alongside the existing "money check" to fix it:
$adopt_premium_price = $_REQUEST["adopt_premium_price"];
$premium_money_check = $mysidia->db->select("users", array("premiumcurrency"), "uid = '{$mysidia->user->uid}'")->fetchColumn();
elseif($premium_money_check < $adopt_premium_price){
$document->add(new Comment("<p>Whoops! You don't have enough premium currency to buy this pet!</p> <a href='/usershop/browse/{$shop_id}'>Continue shopping?</a>"));
return;
}

Abronsyth
12-30-2017, 11:50 AM
Awesome, that was it! Thank you :D

NobodysHero
03-28-2018, 09:27 PM
[28-Mar-2018 22:24:23 America/New_York] PHP Fatal error: Uncaught exception 'LanguageException' with message 'Language var add does not exist.' in /home/mystfell/public_html/classes/class_language.php:68
Stack trace:
#0 /home/mystfell/public_html/view/shopcpview.php(70): Language->__get('add')
#1 /home/mystfell/public_html/classes/class_frontcontroller.php(100): ShopcpView->add()
#2 /home/mystfell/public_html/index.php(74): FrontController->render()
#3 /home/mystfell/public_html/index.php(78): IndexController::main()
#4 {main}
thrown in /home/mystfell/public_html/classes/class_language.php on line 68


Halp?

Also, I removed the premium_price... So, if that's a problem, would be wonderful to know the right way to sell their pets for regular currency.

Thanks!

Dinocanid
03-29-2018, 12:41 PM
Looks like it was a mistake on my end, I forgot to include the lang file ^^;
I included it as an attachment for you.

Selling pets for regular currency is already included in the mod (in the pastebin link). All you would have to do is remove all of the parts that involve premium currency from the pastebin code and the usershop/usershopview code if you don't want to give that option to users. It shouldn't break anything afaik.

NobodysHero
03-29-2018, 09:04 PM
Thanks! That's actually exactly what I did. YAY! Thanks for the mod, it's exciting to be able to offer shops to my users! :happyfaic:

Edit: Actually, three more things. >.< For some reason, it's showing my header image as the background for the URL input?

2nd thing: I can't figure out how to stock my shop?

3rd thing: It doesn't allow the selection of item shop. The radio is stuck on adopts?

Sorry! -hides.-

Dinocanid
03-29-2018, 10:37 PM
With the way it is now, you can only stock your shop from the myadopts page (I plan to add it to the shopCP at some point, but it is possible to make an alternate way in the meantime with the example code if you know how). The pastebin code gives an example of a section on a pet's manage page where you can add/remove them from your shop and for what price.
http://www.clipular.com/c/5754111769968640.png?k=OexdRF0pSrVK5uWz1FHgEPOmgMk
Item shops aren't available/made yet, so adopts is the only selectable option for now.

For the header image, can I see a screenshot? The image is appearing inside the url box?

NobodysHero
03-30-2018, 09:25 AM
Yeah, I included that, but when I go to my pet's profile, it doesn't show anything?

I've attached my code, if you wouldn't mind looking through it? Maybe I missed something. x.x

Here's the image of the creation page:

https://i.imgur.com/EXgElnU.png

Dinocanid
03-30-2018, 09:55 AM
It might be an issue with the code in shopcpview. You can see if changing the following helps:
<input type='text' class='form-control' placeholder='NPC image url' value='{$shop->npc_url}' style='width:50%; name='image' id='image'>
<input type='text' class='form-control' placeholder='NPC image url' value='{$shop->npc_url}' style='width:50%;' name='image' id='image'>
(Added a missing single quotes behind the width)

For the sell code not appearing, I think it's because you placed it inside of the "freeze" function, so you'll only see it on the same page you would freeze the pet. Putting it in "public function manage" will make it show along with everything else, or you could make a new public function.

NobodysHero
03-30-2018, 11:05 AM
Still no luck on either issue. x.x

I've attached both files. If there's another file you need, I'm here for a while. If you have Discord, might make it easier?

NobodysHero#3709

Nairi
09-20-2018, 06:13 AM
(Sorry for my very bad english, i'm from germany)

I have the problem, that i also don't see the sell-options in the pet-manage-profil =/

Dinocanid
09-20-2018, 07:14 AM
Can you show what your code looks like for that page?

Nairi
09-20-2018, 08:20 AM
yes. i think, its a very simple mistake but i'm a little blind at the moment.

thank you

Dinocanid
09-20-2018, 10:00 AM
I think I found it, you pasted the shop code at the end of the manage function, when it should go towards the beginning.

It should work now.

Nairi
09-20-2018, 11:58 AM
Oh, thank you =)

Missy Master
08-05-2020, 01:30 PM
is there a way anyone knows to resize the pet image shown when you go to buy the Pet?

Any help would be great :)

My images are so big they cover the whole deal :/

Abronsyth
08-05-2020, 06:03 PM
Yeah, where it displays the pet I modify my width like this:
<a href='/levelup/publicprofile/{$aid}'><img src='{$image}' style='max-width:100%;'></a></br>
<b>{$adopt->name}</b>
<p>$ {$price}</p>

Missy Master
08-05-2020, 06:12 PM
Thank you!! I appreciate the help, I love the Mod but it helps to be able to see the particulars lol.

This works yay!