Author Topic: [Code] Shop (Beta 02.06.13)  (Read 3542 times)

0 Members and 0 Guests are viewing this topic.

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
[Code] Shop (Beta 02.06.13)
« 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/
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)
« Last Edit: February 07, 2013, 01:46:43 am by xboi209 »
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Share on Facebook Share on Twitter


Offline abugbeary

  • Newbie
  • *
  • Posts: 46
  • Karma: -1
    • View Profile
    • Clans of the Waterfalls
Re: [Code] Shop (Beta 02.06.13)
« Reply #1 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..  ???
Join me in Clans of the Waterfalls! An amazing animal roleplaying site, mostly about cats though...

It is very high-tech, with active members! Join today!

*Click Here*

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
Re: [Code] Shop (Beta 02.06.13)
« Reply #2 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.
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Offline abugbeary

  • Newbie
  • *
  • Posts: 46
  • Karma: -1
    • View Profile
    • Clans of the Waterfalls
Re: [Code] Shop (Beta 02.06.13)
« Reply #3 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!
Join me in Clans of the Waterfalls! An amazing animal roleplaying site, mostly about cats though...

It is very high-tech, with active members! Join today!

*Click Here*

Offline abugbeary

  • Newbie
  • *
  • Posts: 46
  • Karma: -1
    • View Profile
    • Clans of the Waterfalls
Re: [Code] Shop (Beta 02.06.13)
« Reply #4 on: February 19, 2013, 09:53:59 pm »
It does not seem to be working. Any suggestions?
Join me in Clans of the Waterfalls! An amazing animal roleplaying site, mostly about cats though...

It is very high-tech, with active members! Join today!

*Click Here*

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
Re: [Code] Shop (Beta 02.06.13)
« Reply #5 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
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Offline abugbeary

  • Newbie
  • *
  • Posts: 46
  • Karma: -1
    • View Profile
    • Clans of the Waterfalls
Re: [Code] Shop (Beta 02.06.13)
« Reply #6 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.  :)
Join me in Clans of the Waterfalls! An amazing animal roleplaying site, mostly about cats though...

It is very high-tech, with active members! Join today!

*Click Here*

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
Re: [Code] Shop (Beta 02.06.13)
« Reply #7 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
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Offline abugbeary

  • Newbie
  • *
  • Posts: 46
  • Karma: -1
    • View Profile
    • Clans of the Waterfalls
Re: [Code] Shop (Beta 02.06.13)
« Reply #8 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?
Join me in Clans of the Waterfalls! An amazing animal roleplaying site, mostly about cats though...

It is very high-tech, with active members! Join today!

*Click Here*

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
Re: [Code] Shop (Beta 02.06.13)
« Reply #9 on: February 20, 2013, 08:11:57 pm »
I can't see the Trading Den on your forum.
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Offline KIЯBYFAN91

  • Newbie
  • *
  • Posts: 26
  • Karma: 0
  • Gender: Male
    • View Profile
    • Smash Forums
Re: [Code] Shop (Beta 02.06.13)
« Reply #10 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>
Max characters: 300; characters remaining: 254

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
Re: [Code] Shop (Beta 02.06.13)
« Reply #11 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.
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Offline abugbeary

  • Newbie
  • *
  • Posts: 46
  • Karma: -1
    • View Profile
    • Clans of the Waterfalls
Re: [Code] Shop (Beta 02.06.13)
« Reply #12 on: February 21, 2013, 02:11:01 am »
The Trading Den is *here*. You probably couldn't see it because you weren't logged in or registered.
Join me in Clans of the Waterfalls! An amazing animal roleplaying site, mostly about cats though...

It is very high-tech, with active members! Join today!

*Click Here*

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile
Re: [Code] Shop (Beta 02.06.13)
« Reply #13 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.
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

Offline abugbeary

  • Newbie
  • *
  • Posts: 46
  • Karma: -1
    • View Profile
    • Clans of the Waterfalls
Re: [Code] Shop (Beta 02.06.13)
« Reply #14 on: February 22, 2013, 01:02:33 am »
Okay. Thanks anyway.
Join me in Clans of the Waterfalls! An amazing animal roleplaying site, mostly about cats though...

It is very high-tech, with active members! Join today!

*Click Here*

 

Related Topics

  Subject / Started by Replies Last post
1 Replies
1131 Views
Last post September 30, 2012, 05:23:55 pm
by aIURbliS
7 Replies
1277 Views
Last post March 18, 2013, 02:55:49 am
by aIURbliS
4 Replies
1064 Views
Last post March 09, 2013, 06:26:27 pm
by abugbeary
0 Replies
870 Views
Last post July 22, 2013, 03:29:19 am
by aIURbliS
4 Replies
1001 Views
Last post January 17, 2018, 02:37:34 am
by CreateAForum