Create A Forum - Support Forums

Support => Create a Forum Codes and Support => Topic started by: aIURbliS on February 07, 2013, 01:32:56 am

Title: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on February 07, 2013, 01:32:56 am
Description: This code is currently in beta stage, there's limited functionality as of right now.
It is required to make a new profile field with the following settings:
Quote
Name: Items
Description:
Profile Section: Forum Profile
Show on Registration: No
Choose Placement: Above Signature
Show Enclosed Within Text: <b>Items:</b> {INPUT}
Field Type: Text
Maximum Length: 0
Allow BBC: No
Input Mask: No HTML
Privacy: Users can see this field; owner can edit it
Searachble: Yes
Active: Yes
The shop page is located on: http://URL.createaforum.com/index.php?action=shop

Deprecated Elements/Attributes Warning: This code uses the Center element which is no longer supported in HTML5.

This code utilizes jQuery, please use the latest version found in this thread: http://support.createaforum.com/5/jquery-v1-8-update/ (http://support.createaforum.com/5/jquery-v1-8-update/)
Footers:
Code: [Select]
<script>
//Created by xboi209
//Version: Beta 02.06.13
if (location.href == smf_scripturl + "?action=shop") {
    $("#main_content_section").html("<center><div id='shop'><table frame='box' cellspacing='10' width='600'><tr><th>Item</th><th>Description</th><th>Price</th><th>Buy</th></tr><tbody id='row'></tbody></table><></center>");
}
if (location.href == smf_scripturl + "?action=shop;page=buy") {
    $("#main_content_section").html("<center><div id='shop_buy'><table frame='box' cellspacing='10' width='600' id='shop_table'><tr><th>Are you sure?</th></tr><tr><td><tbody id='buy_formtest'></tbody></td></tr></table><div id='buy_button'><><></center><br>");
    purchase();
}
if (location.href == smf_scripturl + "?action=profile;area=forumprofile;updated" && localStorage.getItem("purchased") == "true") {
    localStorage.setItem("purchased","false")
    window.location = smf_scripturl + "?action=shop;page=purchased";
}
if (location.href == smf_scripturl + "?action=shop;page=purchased") {
    $("#main_content_section").html("<center><div class='windowbg' id='profile_success'>You have successfully purchased " + localStorage.getItem("item") + "!<br><a href='"+smf_scripturl+"?action=shop'>Return to Shop</a></center>");
}
if (location.href >= smf_scripturl + "?action=profile") {
    $.get(smf_scripturl + "?action=shop", function(data){
//        console.log($(data).find("#row"));
//        localStorage.setItem("item1",$("#shop > a").attr("data-item"));
    });
}
function purchase(){
    $("#buy_button").load(smf_scripturl+"?action=profile;area=forumprofile #main_admsection", function() {
    $("#creator").appendTo("#main_content_section").wrap("<div id='center_purchase' style='margin: 0 auto;width: 67px;' />");
    $("div.righttext").prependTo("#creator");


    $("input[value='Change profile']").attr("value","Purchase");
    $("input[value='Purchase']").click(function(){localStorage.setItem("purchased","true")});


    $("#buy_formtest").prepend("<b>Item:</b> "+localStorage.getItem("item")+"<br><b>Description:</b> "+localStorage.getItem("description")+"<br><b>Price:</b> "+localStorage.getItem("price"));
    $("#creator > div.cat_bar,p.windowbg.description,div.windowbg2:not(input[value='Purchase'])").hide();
    $("input[name='customfield[cust_items]']").val( $("input[name='customfield[cust_items]']").val() + "{" +  localStorage.getItem("item") + "}");
    });
}
function main_shop(item, description, price) {
    $("#row").append("<tr><td align='middle' id='"+item+"'>" + item + "</td><td align='middle' id='"+description+"'>" + description + "</td><td align='middle' id='"+price+"'>" + price + "</td><td align='middle'><a href='"+smf_scripturl+"?action=shop;page=buy' data-item='"+item+"' data-description='"+description+"' data-price='"+price+"'>Purchase</a></tr>");
    $("td > a").click(function(){
        localStorage.setItem("item",$(this).attr("data-item"));
        localStorage.setItem("description",$(this).attr("data-description"));
        localStorage.setItem("price",$(this).attr("data-price"));
    });
}
main_shop("ITEM1", "DESCRIPTION1", "PRICE1");
main_shop("ITEM2", "DESCRIPTION2", "PRICE2");
main_shop("ITEM3", "DESCRIPTION3", "PRICE3");
</script>

Editing Instructions: Add more of these lines main_shop("ITEM1", "DESCRIPTION1", "PRICE1"); to the end of the code for more items

Compatibility:
Spoiler (hover to show)
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: abugbeary on February 19, 2013, 07:21:31 am
Thank you for the wonderful code! I have been looking for a code like this!  ;D


One slight problem, where do I put it? I did the profile field..  ???
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on February 19, 2013, 08:54:27 pm
You need to add jQuery to your Headers, the code is here:
http://support.createaforum.com/5/jquery-v1-8-update/
The shop code itself goes to the Footers.
The Headers and Footers are located in the Style Manager.
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: abugbeary on February 19, 2013, 09:42:42 pm
Thank you so much! I had already added the jQuery to the header, I just did not know where to put the shop. Thanks again for the helpful info!
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: abugbeary on February 19, 2013, 09:53:59 pm
It does not seem to be working. Any suggestions?
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on February 20, 2013, 12:15:41 am
I looked at your forum and there's 2 problems:
1) You placed the shop code in the Meta Tags area, not the Footers
2) You didn't copy and paste the code correctly
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: abugbeary on February 20, 2013, 12:53:25 am
I have it in both the meta tags and footers. I will go and fix the code, and see if that works.  :)
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on February 20, 2013, 05:55:58 am
I don't even see the shop code at all anymore. Also, the code isn't expected to work if you put it in the meta tags area
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: abugbeary on February 20, 2013, 04:39:11 pm
It is in the footers area only now. It does seem to be working. Do you know how to make the code look like the section "Trading Den" in my forum?
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on February 20, 2013, 08:11:57 pm
I can't see the Trading Den on your forum.
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: KIЯBYFAN91 on February 21, 2013, 12:15:50 am
Wait, the center tag doesnt work?
I thought it did
It worked for me before on my Google Site by typing <align=center>text</align>
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on February 21, 2013, 01:48:06 am
It does work however it's not supported in HTML5, the warning is simply there because if CreateAForum ever switches to HTML5 or a Strict doctype, this code would make your forum invalid. Also in the future(not anytime soon), the center tag will eventually be removed once it's not in widespread use.
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: abugbeary on February 21, 2013, 02:11:01 am
The Trading Den is *here* (http://clansofthewaterfalls.createaforum.com/index.php?action=ezportal;sa=page;p=32). You probably couldn't see it because you weren't logged in or registered.
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on February 21, 2013, 09:24:36 pm
Well I can't see the Trading Den because of permissions that are set and I don't think I want to customize the code right now.
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: abugbeary on February 22, 2013, 01:02:33 am
Okay. Thanks anyway.
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: Wu_Zi_Mu on May 30, 2013, 03:57:34 am
Well i just bought an item but i didn't lose anything. Any ideas on making a donation system? Like E-Shop?
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: simsfreak on June 20, 2013, 07:24:44 am
I was wondering if there was any way to link a money system to the shop system? I don't want a literal store on the forum, but just a place where you post and earn funds and buy a virtual item. Like a pic, or a graphic of some kind. The shop code works great, but I have to keep track of people's funds and send out messages every day with their statistics. It's very time consuming and getting me down. Also, doing specific things earns funds not just posting. Like, helping someone with a computer issue, I would reward that helper with extra funds for the day, so having the ability for admin/global to modify the amount would be outstanding! If it's too difficult, or not possible, break it to me gently... lol
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on July 17, 2013, 08:09:50 am
There currently isn't a money system for this code.
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: CyanProductions on November 09, 2014, 12:49:40 am
Is this going to be updated?
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: CyanProductions on November 15, 2014, 11:02:56 pm
I just added my own money system to it, but there is a huge flaw with the code, users purchasing must have permission to edit the fields making this useless.
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: Nekoruchii on December 08, 2014, 01:21:27 pm
Well i just bought an item but i didn't lose anything.


Same here though. :/ this is one of the codes that I loved so far >_________<
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: aIURbliS on December 13, 2014, 08:20:23 pm
I just added my own money system to it, but there is a huge flaw with the code, users purchasing must have permission to edit the fields making this useless.
There isn't any better way to implement this without creating a server to store the information in
Title: Re: [Code] Shop (Beta 02.06.13)
Post by: koleradeniz on December 20, 2014, 02:36:36 pm
Thanks..