SitePoint Sponsor

User Tag List

Results 1 to 9 of 9
  1. #1
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    best way to do this

    I have an Exel spreadsheet that does mathamatical equations. It basicly allows me to input the amount of t-shirts desired and it will give me a quote to submit to my clients. I want to makesomthing like this on like so clients can get a real time price dependant on what they desire. I am not asking someone to do this I want to learn and if it takes me a while to do this then so be it. I am needing pointers and guildance on planning.Pat

  2. #2
    SitePoint Enthusiast Gerald Winter's Avatar
    Join Date
    Apr 2009
    Posts
    99
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just create an array with quantity - discount
    then do a lookup: if quantity > x discount = y
    and let it do the math
    Gerald Winter
    Tips from Mr Bigcheck to make your check Bigger
    Save money on all inclusive vacation packages

  3. #3
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks Gerald, I am looking forward to trying to do this. I will be my first attempt at anything real in PHP There will be lots of if's and elseif's. I am writing down on paper what I will need it to do like a blueprint. That may help me stay focused. There are many different manufactures with different style t-shirts and prices. I also do screenprinting so there is an added cost per t-shirt per color and per image. See where I'm going to here. I will then have the final information incorperated into my shopping cart osCommerce. But I did do research on mathamatical functions and data bases this evening.PatPat

  4. #4
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do something like this:

    Code:
    Create an html page with this form on it: (action=filename needs to be quote dot php but i can't post links in my posts, dammit.
    
    <form name="shorts" method="post" action="filename">
      <input name="qty" type="text" />
      <input name="submit" type="submit" value="submit">
    </form>
    
    Create a php page called quote like this:
    
    <?php
    
    $qty = stripslashes($_POST['qty']); // this grabs the number they entered on the previous page... stripslashes strips out any nastyness.
    $taxpercent = '0.081';
    
    if ($qty == '0') {
      $msg = "Dude, where's my Qty?";
    }
    
    elseif ($qty <= 50) {
      $pricepershirt = "10.00";
      $subtotal = $pricepershirt * $qty; // calculates subtotal amount
      $tax = $subtotal * $taxpercent;
      $shipping = however you define this;
      $total = $subtotal + $tax + $shipping;
      }
    
    elseif ($qty <= 100) {
      $pricepershirt = "9.00";
      $subtotal = $pricepershirt * $qty; // calculates subtotal amount
      $tax = $subtotal * $taxpercent;
      $shipping = however you define this;
      $total = $subtotal + $tax + $shipping;
      }
    
    elseif ($qty <= 150) {
      $pricepershirt = "8.00";
      $subtotal = $pricepershirt * $qty; // calculates subtotal amount
      $tax = $subtotal * $taxpercent;
      $shipping = however you define this;
      $total = $subtotal + $tax + $shipping;
      }
    
    etc. etc. for more layers of discount... 
    
    then build your webpage, and whereever you want it to display the total amount, use:
    
    echo '$total';
    
    ?>
    You could use an array, a case etc. but if you only have 4 or 5 levels of discount, an if statement works fine.

  5. #5
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    or you could store the price of each shirt in a database, so you have ten manufacturers and each of them has 20 items, so you have 200 products. So, you have 200 rows in your products table... figger out a way to add a field that says how much discount each item has at certain qtys, like maybe have a qty20 field with 10% in it, and a qty100 field with 15% in it etc. and pull that out with a query, then do an if statement where you multiply that onto the total.

  6. #6
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yep the if statement would work fine. But like you pointed out I have different manufacturers and sizes. The prices are for s to and including XL the price goes up for xxl and xxxl and so on. Also lets say they have a one color image on the back only then that is one price but if they have two colors in the image that adds to the per price. I have been reading on setting up a database for this. I also need to work on setting up a color chart that would allow clients to see the color and select it with out having to go to another page. Then the issue will be to tie this ll in with osCommerce. I do like the start and ideas you are all giving me though lots to think about in my planning. I will have to book mark this posting so I dont loose it when I start to do the actual coding. I hope this is by the end of the weekend.
    Pat

  7. #7
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On the colors... make a grid of CSS squares, say you have 9 colors, so you have a grid of 3 across by 3 tall... anyhow, when they click on that color, link it to another php page, and that page, a script, inserts that color code into a session variable, and then you can use it to calculate so...

    Have an external CSS file with the outer square called "colors" and then 9 smaller divs for each color...

    .colors {
    height: 360px;
    width: 360px;
    }

    .red {
    height: 90px;
    width: 90px;
    background-color: red; // or hex color for red, whatever...
    }

    .
    .
    .
    etc. for all colors...

    On your order page...

    <div class="colors">
    <div class="red"></div>
    <div class="blue"></div>
    <div class="green"></div>
    <div class="yellow"></div>
    <div class="purple"></div>
    <div class="black"></div>
    <div class="silver"></div>
    <div class="scumgreen"></div>
    <div class="white"></div>
    </div>

    You'll have to put them in a for loop, so it does three, line breaks, does three more, line breaks..

    The link for red would be like <a href="selectcolor.php?color=FF0000">

    Then in the selectcolor.php page..

    $color = $_GET['color'];

    and then register that with the session with session_register..

    header redirect back to the order page, and now you can use $color to set the price.

    Is that all drivel?

    LOL if you get stuck post back up, I'd love to help code a color picker, kinda cool idea.

  8. #8
    SitePoint Addict Kysmiley's Avatar
    Join Date
    Dec 2004
    Location
    Isonville KY
    Posts
    304
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I Like the Idea of CSS for the colors. I may have do do a few of them. Some manufacturers only have certain colors while others have more. So you can see some of the complexity I may be running into. But my mind is racing, like I said the sky is the limit on what I may be able to do with this one.
    Thank-you very much for all your input so far. Like I said I am a newby so I am having fun learning this stuff finally. Like others said dont let age get in the way of my learning LOL
    Pat

  9. #9
    SitePoint Enthusiast
    Join Date
    Apr 2009
    Posts
    90
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yeah man, just set a reasonable timeline, do tons of research and work at it a little every day. I generally have 5 clients going at once and learn a lot as I go. I'm retty good with XHTML/CSS and decent at PHP, but I spend probably 20 hours a week just learning. There's tons of blogs that will help too, like Net Tuts, Smashing Magazine, Line25 etc... just read, read, read and learn, learn, learn...


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •