Results 1 to 3 of 3

Thread: Price adjustment in multiple pieces.

  1. #1
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default Price adjustment in multiple pieces.

    I want to give a discount when the customer wants more than 2 of the same products.
    The price shown must be the price minus the discount (see discounts on testpage).
    There is also a "size option" which adjust the standard price of the product, this script works fine.
    But my script for the discount doesn't work.

    See testpage.




    Files in zip.
    Attached Files Attached Files

  2. #2
    Join Date
    Dec 2008
    Location
    Portsmouth, UK
    Posts
    1,891
    Thanks
    2
    Thanked 441 Times in 435 Posts

    Default

    Code:
    function getPrice(option, prodPrice) {
    var prodPrice = parseFloat(prodPrice.replace(",","."));
    var thePrice;
      switch (option) {
        case '10':
    	  thePrice = (prodPrice-1).toFixed(2);
    	  break;
    	case '15':
    	  thePrice =  prodPrice.toFixed(2);
    	  break;
    	case '20':
    	  thePrice = (prodPrice+2).toFixed(2);
    	  break;
    	case '25':
    	  thePrice = (prodPrice+4).toFixed(2);
    	  break;
    	case '30':
    	  thePrice = (prodPrice+5).toFixed(2);
    	  break;
    	case '35':
    	  thePrice = (prodPrice+6).toFixed(2);
    	  break;
    	case '40':
    	  thePrice = (prodPrice+7).toFixed(2);
    	  break;
    	case '45':
    	  thePrice = (prodPrice+8).toFixed(2);
    	  break;
    	case '50':
    	  thePrice = (prodPrice+9).toFixed(2);
    	  break;
    	case '55':
    	  thePrice = (prodPrice+10).toFixed(2);
    	  break;
    	default:
    	  thePrice =  prodPrice.toFixed(2);
     }
     nu=document.getElementById('stickersBE_1_Quantity_Add').value;
      thePrice=thePrice*nu;
      if (nu>2){
       if (nu<6){
        thePrice-=thePrice/20;
       }
       if (nu<10){
        thePrice-=thePrice/30;
       }
       else{
        thePrice-=thePrice/25;
       }
      }
    //DISCOUNT : 1-2 pcs : no discount  ***  3-5 pcs : -20%  ***  6-9 pcs : -30%  ***  > 10 pcs : -35%
    
     return (thePrice.toFixed(2)+'').replace('.',',');
    }
    Vic
    God Loves You and will never love you less.
    http://www.vicsjavascripts.org/Home.htm
    If my post has been useful please donate to http://www.operationsmile.org.uk/

  3. #3
    Join Date
    Feb 2010
    Posts
    63
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Default

    thanks

Similar Threads

  1. Get price from DB echo different price
    By PatrikIden in forum PHP
    Replies: 18
    Last Post: 11-25-2011, 09:32 PM
  2. virtual pagination - pieces per page
    By mlk83 in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 08-14-2009, 06:59 PM
  3. Mulitple pieces of content within a slide
    By mkobus in forum Dynamic Drive scripts help
    Replies: 2
    Last Post: 03-27-2008, 06:35 PM
  4. help with an adjustment...
    By dburlington in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 01-24-2008, 12:10 AM
  5. Hiden form pieces shown when user accepts agreements...
    By Rockonmetal in forum JavaScript
    Replies: 1
    Last Post: 05-10-2007, 11:16 AM

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
  •