News:

Create A Forum Installed

Author Topic: [Code] Shop (Beta 9.30.12)  (Read 1460 times)

0 Members and 3 Guests are viewing this topic.

Offline aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile

Badges: (View All)
Level 6 Sixth year Anniversary Fifth year Anniversary
[Code] Shop (Beta 9.30.12)
« on: September 30, 2012, 05:23:17 pm »
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:
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


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 9.30.12
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'><tr><th>Are you sure?</th></tr><tr><td><tbody id='buy_formtest'></tbody></td></tr></table><></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_formtest").load(smf_scripturl+"?action=profile;area=forumprofile #main_admsection", function() {
    $("#creator").prependTo("#buy_formtest");
    $("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
« Last Edit: October 06, 2012, 12:36:31 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 aIURbliS

  • Hero Member
  • *****
  • Posts: 1215
  • Karma: 45
  • Gender: Male
  • Location: U.S.
    • View Profile

Badges: (View All)
Level 6 Sixth year Anniversary Fifth year Anniversary
Re: [Code] Shop (Beta 9.30.12)
« Reply #1 on: September 30, 2012, 05:23:55 pm »
Successfully tested on:
•Chrome 14
•Chrome 24
•Internet Explorer 8
•Internet Explorer 9
•Internet Explorer 10(Desktop)
•Safari 4.0
•Safari 5.0(+minor bug)
•Safari 5.1(+minor bug)
•Opera 10.0
•Opera 11.1
•Opera 11.5

Incompatible with:
•Firefox(all)
•Opera 11.6+
« Last Edit: February 03, 2013, 05:28:40 am by xboi209 »
All codes I make are tested on the latest version of Google Chrome and upon request of other browsers.

 

Related Topics

  Subject / Started by Replies Last post
2 Replies
1258 Views
Last post January 19, 2012, 03:10:52 am
by Corgz
7 Replies
1575 Views
Last post March 18, 2013, 02:55:49 am
by aIURbliS
22 Replies
4398 Views
Last post December 20, 2014, 02:36:36 pm
by koleradeniz
4 Replies
1317 Views
Last post March 09, 2013, 06:26:27 pm
by abugbeary
0 Replies
1022 Views
Last post July 22, 2013, 03:29:19 am
by aIURbliS