We hope you enjoy your visit.

You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free.


Join our community!


If you're already a member please log in to your account to access all of our features:

Username:   Password:
Add Reply
  • Pages:
  • 1
Simple Semi-Automatic Shop System; ZetaBoards Dynamo Add-on
Topic Started: Aug 29 2014, 09:16 PM (3,644 Views)
Viral
Member Avatar
Viral
[ *  *  *  *  *  * ]
What it does: Adds a simple shop page where admins can add items and list it at whatever price they want. Users can buy these items and have their money deducted automatically and a notification will be sent to the seller to tell them that their item has been bought. Admins have to add the items, but can add items for members on their behalf.

Preview: Here (you will need an account).

Prerequisites: You must be using ZetaBoards Dynamo for this to work.

How to install: You will set this up on a separate web page. To do this, go to: Admin CP >> Board Customization >> Website Maker >> Create new Webpage. You can choose whatever you want for the page id and title. For the content add the following:

Code:
 
<div id="simple_shop" class="dynamo_loader" />


Code: This is the main code. Add this to: Admin CP >> Themes >> Board Template >> Below the Board
Code:
 
<script type="text/javascript">
//<![CDATA[
if($("#simple_shop").size()) {
$("body").on("dynamo_loaded", function() {

// Simple semi-automatic shop by Viral of http://viralsmods.com
// You must be using ZetaBoards Dynamo for this to work http://dynamo.viralsmods.com

var options = {
preview_image : {
_default : "defaultpreviewimagelink.png", // image to show when none is given (leave blank for N/A)
width : '50px',
height : '50px'
},
message : "I have purchased an item from your shop (item ID: %ITEMID%)." // %ITEMID% gets replaced with the item's id
};

var items = [];

items[items.length] = {
id : "item-id",
seller : [user_id, "username"],
preview_image : "imagelink.png",
name : "Item name",
desc : "Item description",
price : 200
};

/* END OF EDITS */

if("currency" in dynamo.server.modules) {

var symbol = dynamo.server.modules.currency.settings.symbol;

window.buyItem = function(itemID, userID, price) {
var formatted_price = dynamo.toolbox.format_number(price);
var confirmation = confirm("Are you sure you want to purchase this item for " + symbol + formatted_price + "?");
if(confirmation) {
dynamo.module.load("currency", function() {
dynamo.tip.prompt.ini({
m : "currency",
p1 : "donate",
c : "finish",
zbids : [userID],
info : {
user : userID,
message : options.message.replace(/%ITEMID%/gi, itemID),
amount : price
}
});
});
}
};

var rows = [{
cells : [
{
content : 'Preview',
type : 'th',
style : {
width : options.preview_image.width
}
},
{
content : 'Seller',
type : 'th'
},
{
content : 'Name',
type : 'th'
},
{
content : 'Description',
type : 'th'
},
{
content : 'Price',
type : 'th'
},
{
content : 'Buy Item',
type : 'th'
}
]
}], i, item, preview;

for(i in items) {
item = items[i];
formatted_price = dynamo.toolbox.format_number(item.price);
preview = item.preview_image.length ? item.preview_image : options.preview_image._default;
preview = preview.length
? '<img src="' + preview + '" alt="' + item.name + '" width="' + options.preview_image.width + '" height="' + options.preview_image.height + '" />'
: 'N/A';
rows[rows.length] = {
cells : [
{
content : preview,
style : {
align : 'center'
}
},
{content : '<a href="' + main_url + 'profile/' + item.seller[0] + '">' + item.seller[1] + '</a>'},
{content : item.name},
{content : item.desc},
{content : symbol + formatted_price},
{content : '<a href="javascript:buyItem(\'' + item.id + '\', ' + item.seller[0] + ', ' + item.price + ');">Buy</a>'}
]
};
}

dynamo.table.create("#main .site_wrapper", {
colspan : 6,
rows : rows
});

} else {
$("#main .site_wrapper").html('The shop cannot be loaded as the currency system has not been installed.');
}

});
}
//]]>
</script>


Instructions: Note that this code will not work until you add your own items. To do this, find the block which looks like:

Code:
 
items[items.length] = {
id : "item-id",
seller : [user_id, "username"],
preview_image : "imagelink.png",
name : "Item name",
desc : "Item description",
price : 200
};


This block will add one item to your webpage. As it is at the moment, it will not work. You need to edit it to suit your needs!

1) Change `"item-id"` (2nd line) to whatever you think signifies this item. It must be meaningful as this is how the seller can tell what item his/her buyer has purchased. Keep the speech marks.
2) Change `user_id` (3rd line) to the ID of the seller. You can find their ID by going to their profile page and copying the numbers at the end of the URL. A link to my profile is: http://if.invisionfree.com/profile/230248/ - my ID is 230248. No speech marks this time, but make sure the comma stays there!
3) Change `"username"` (3rd line)to the username of the seller. Keep the speech marks.
4) Change `"imagelink.png"` (4th line) to a link to a preview image of the item. If one does not exist, leave it blank (`""`). Keep the speech marks!
5) Change `"Item name"` (5th line) to the item's name. Keep the speech marks.
6) Change `"Item description"` (6th line) to a description of the item. Keep the speech marks.
7) Change `200` (7th line) to the price of the item. No speech marks, and no comma at the end!

So how do I add more items?

Simple! Copy and paste the block above so you have two of them! For example, I could have two items by using the following code:

Spoiler: click to toggle


Any other settings I can change?

At the top of the code, you will see the following block:

Code:
 
var options = {
preview_image : {
_default : "defaultpreviewimagelink.png", // image to show when none is given (leave blank for N/A)
width : '50px',
height : '50px'
},
message : "I have purchased an item from your shop (item ID: %ITEMID%)." // %ITEMID% gets replaced with the item's id
};


This are a few options that can be edited to suit your needs.

1) Change `"defaultpreviewimagelink.png"` (3rd line) to the default preview image if you do not specify one in the item. You can leave this blank (`""`) if you want. Again, keep the speech marks!
2) The width and height can be changed respectively (these are the dimensions of the preview image).
3) To change the message sent to the seller, change `"I have purchased an item from your shop (item ID: %ITEMID%)."`. You can use the dynamic text `%ITEMID%` which will automatically change to the item's ID which is being purchased.

Notes: This system uses Dynamo's donation system in the background. For this reason, you must have the currency system installed (which should be obvious if you're building a shop :P). Also note that all limitations on donations are also set for buying items because of this. For example, if a group has been set to not be allowed to donate, then that means that they cannot buy items in the shop either.




If you have any questions, please ask - but do try adding this yourself first!
Edited by Viral, Aug 30 2014, 12:08 AM.
Offline Profile Quote Post Goto Top
 
nickhguitar
Member
[ * ]
Thank you so much again Viral, this makes the Dynamo code complete for me.

I do however have 1 question; I've just added everything, but i have a edited top menu for the skin (as you can see here: http://w11.zetaboards.com/TimesOfHogwarts/index/). Where/how do i find where my store is now? In other words, how can i add a link to the top menu?
Offline Profile Quote Post Goto Top
 
Viral
Member Avatar
Viral
[ *  *  *  *  *  * ]
This should do what you want :) .
Offline Profile Quote Post Goto Top
 
nickhguitar
Member
[ * ]
Viral
Aug 31 2014, 12:35 PM
This should do what you want :) .
thx so much ^_^ 1 more question; would it be possible to make categories in the shop? Now it's 1 big shop, but i would like to make 5/6 shops..
Offline Profile Quote Post Goto Top
 
Viral
Member Avatar
Viral
[ *  *  *  *  *  * ]
Not with this one (at the moment at least).
Offline Profile Quote Post Goto Top
 
nickhguitar
Member
[ * ]
Viral
Aug 31 2014, 02:00 PM
Not with this one (at the moment at least).
allright thx, Btw, the code on the link you've send me doesn't work for me.. I've installed it at the very bottom of below the board, but the shop still doesn't show up. Can you please take a look for me if i send you my login details?
Offline Profile Quote Post Goto Top
 
Viral
Member Avatar
Viral
[ *  *  *  *  *  * ]
Please post in the topic I linked to and the code's creator will be able to help you.
Offline Profile Quote Post Goto Top
 
Ferby
Member Avatar
Developer
[ *  *  *  *  * ]
Viral
Aug 31 2014, 02:27 PM
Please post in the topic I linked to and the code's creator will be able to help you.
I wonder who that could be :r :tut: :puppyeyes:
Offline Profile Quote Post Goto Top
 
nickhguitar
Member
[ * ]
Ferby
Aug 31 2014, 02:58 PM
Viral
Aug 31 2014, 02:27 PM
Please post in the topic I linked to and the code's creator will be able to help you.
I wonder who that could be :r :tut: :puppyeyes:
Again thanks for the help ;) Last question before i shut up; Maybe this is a dumb/stupid question. But where do the bought items go? Is there a inventory or something like that?
Offline Profile Quote Post Goto Top
 
Ferby
Member Avatar
Developer
[ *  *  *  *  * ]
nickhguitar
Aug 31 2014, 03:33 PM
Ferby
Aug 31 2014, 02:58 PM
Viral
Aug 31 2014, 02:27 PM
Please post in the topic I linked to and the code's creator will be able to help you.
I wonder who that could be :r :tut: :puppyeyes:
Again thanks for the help ;) Last question before i shut up; Maybe this is a dumb/stupid question. But where do the bought items go? Is there a inventory or something like that?
It really depends on what the item is. No, there is no inventory system as the shop isn't designed for one sort of item. If I set up a shop for graphics for a specific users and a user bought an avatar for $50 (Dynamo currency) then the money would be automatically sent to them and they would have to supply the user with an avatar of their design. This is why this code is "Semi-Automatic" because it requires some administration from the user to deal with what the user has purchased. Since your forum is an RPG, I would assume that you would like a shop for wands and such. In which case it would be then down to staff to deal with adding such things or, as I've seen on another reliable Harry Potter RPG site, you trust the member to add it themselves and punish any users who cheat the system.

So to answer you, unfortunately not :)
Offline Profile Quote Post Goto Top
 
nickhguitar
Member
[ * ]
That's ok, at least i know now :)
Offline Profile Quote Post Goto Top
 
Valfor
Member
[ * ]
What about adding the ability to sell "stocks"? Is this possible?
Edited by Valfor, Sep 1 2014, 12:58 AM.
Offline Profile Quote Post Goto Top
 
Ferby
Member Avatar
Developer
[ *  *  *  *  * ]
Valfor
Sep 1 2014, 12:58 AM
What about adding the ability to sell "stocks"? Is this possible?
I like the idea but, unfortunately, it's something only Viral would be able create.
Offline Profile Quote Post Goto Top
 
Valfor
Member
[ * ]
Ferby
Sep 1 2014, 07:58 AM
Valfor
Sep 1 2014, 12:58 AM
What about adding the ability to sell "stocks"? Is this possible?
I like the idea but, unfortunately, it's something only Viral would be able create.
Ah. Well, I think it would be a very cool thing to have.

On my board, we're sort of testing this out to get an economy going.

I just thought of this because some things/people may not have anything to sell, but may want to "sell" part of their company (for example, a newspaper).
Offline Profile Quote Post Goto Top
 
Viral
Member Avatar
Viral
[ *  *  *  *  *  * ]
It's a simple shop, admins can add items for themselves or other members to the shop, users can purchase the items. The only automation here is that the seller gets a message when their item is bought and the money is automatically deducted. If you can find a way to trade stocks with those features, then you can do it, otherwise, you can't :P .
Offline Profile Quote Post Goto Top
 
1 user reading this topic (1 Guest and 0 Anonymous)
Go to Next Page
« Previous Topic · ZetaBoards Codes & Modifications · Next Topic »
Add Reply
  • Pages:
  • 1