Advertisement

11.13.2007 at 06:40PM PST, ID: 22959046
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

4.2

PHP coding assistance, in function tags I believe

Asked by twistedindustries in PHP and Databases, PHP Scripting Language

Tags: , ,

I am trying to build in a customer discount into my page.  All pricing comes from a priceformatter.php page (see code below) and I need to call the specific discount which will come from the table customers and the row customers_discount.  I can't seem to get it

Here is the code for priceformatter.php:
<?php
/*
  $Id: PriceFormatter.php,v 1.7 2006/12/23 JanZ Exp $

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2003 osCommerce

  Released under the GNU General Public License
*/

/*
    PriceFormatter.php - module to support quantity pricing

    Created 2003, Beezle Software based on some code mods by WasaLab Oy (Thanks!)
*/

class PriceFormatter {
  var $hiPrice;
  var $lowPrice;
  var $quantity;
  var $hasQuantityPrice;

  function PriceFormatter($prices=NULL) {
    $this->productsID = -1;

    $this->hasQuantityPrice=false;
    $this->hasSpecialPrice=false;

    $this->hiPrice=-1;
    $this->lowPrice=-1;

    for ($i=1; $i<=8; $i++){
      $this->quantity[$i] = -1;
      $this->prices[$i] = -1;
    }
    $this->thePrice = -1;
    $this->specialPrice = -1;
    $this->qtyBlocks = 1;

    if($prices)
      $this->parse($prices);
  }

      /* encode and decode is not used in osC so why load this code?
  function encode() {
      $str = $this->productsID . ":"
             . (($this->hasQuantityPrice == true) ? "1" : "0") . ":"
             . (($this->hasSpecialPrice == true) ? "1" : "0") . ":"
             . $this->quantity[1] . ":"
             . $this->quantity[2] . ":"
             . $this->price[1] . ":"
             . $this->price[2] . ":"
             . $this->specialPrice . ":"
             . $this->qtyBlocks . ":"
             . $this->taxClass;
      return $str;
  }

  function decode($str) {
      list($this->productsID,
           $this->hasQuantityPrice,
           $this->hasSpecialPrice,
           $this->quantity[1],
           $this->quantity[2],
           $this->price[1],
           $this->price[2],
           $this->thePrice,
           $this->specialPrice,
           $this->qtyBlocks,
           $this->taxClass) = explode(":", $str);

      $this->hasQuantityPrice = (($this->hasQuantityPrice == 1) ? true : false);
      $this->hasSpecialPrice = (($this->hasSpecialPrice == 1) ? true : false);
  } */

  function parse($prices) {
    $this->productsID = $prices['products_id'];
    $this->hasQuantityPrice=false;
    $this->hasSpecialPrice=false;

    $this->quantity[1]=$prices['products_price1_qty'];
    $this->quantity[2]=$prices['products_price2_qty'];
    $this->thePrice=$prices['products_price'];
    $this->specialPrice=$prices['specials_new_products_price'];
    $this->hasSpecialPrice=tep_not_null($this->specialPrice);

      $this->price[1]=$prices['products_price1'];
    $this->price[2]=$prices['products_price2'];


     /*
       Change support special prices
         If any price level has a price greater than the special
         price lower it to the special price
      */
      if ($this->hasSpecialPrice == true) {
            for($i=1; $i<=8; $i++) {
                  if ($this->price[$i] > $this->specialPrice)
                        $this->price[$i] = $this->specialPrice;
            }
      }
      //end changes to support special prices

    $this->qtyBlocks=$prices['products_qty_blocks'];

    $this->taxClass=$prices['products_tax_class_id'];

    if ($this->quantity[1] > 0) {
      $this->hasQuantityPrice = true;
      $this->hiPrice = $this->thePrice;
      $this->lowPrice = $this->thePrice;

      for($i=1; $i<=8; $i++) {
      if($this->quantity[$i] > 0) {
        if ($this->price[$i] > $this->hiPrice) {
          $this->hiPrice = $this->price[$i];
        }
        if ($this->price[$i] < $this->lowPrice) {
          $this->lowPrice = $this->price[$i];
        }
      }
      }
    }
  }

  function loadProduct($product_id, $language_id=1)
  {
    global $pfs;
       
    $pricebreak = $pfs->getPriceBreak($product_id);
    // returns false if the price break information is not yet stored
    if ($pricebreak != false) {
        $product_info = $pricebreak;
    } else {        
   $sql = "select pd.products_name, p.products_model, p.products_image, p.products_id," .
   " p.manufacturers_id, p.products_price, p.products_weight, p.products_quantity, " .
   " p.products_price1, p.products_price2, p.products_price3,p.products_price4, " .
       " p.products_price5, p.products_price6, p.products_price7, p.products_price8," .
   " p.products_price1_qty, p.products_price2_qty, p.products_price3_qty, p.products_price4_qty, " .
       " p.products_price5_qty, p.products_price6_qty, p.products_price7_qty, p.products_price8_qty," .
   " p.products_qty_blocks, p.products_tax_class_id," .
   " IF(s.status, s.specials_new_products_price, NULL) as specials_new_products_price " .
   " from " . TABLE_PRODUCTS . " p left join " . TABLE_SPECIALS . " s on p.products_id = s.products_id, " .
   " " . TABLE_PRODUCTS_DESCRIPTION . " pd " .
   " where p.products_status = '1'" .
   " and pd.products_id = p.products_id " .
   " and p.products_id = '" . (int)$product_id . "'" .
   " and pd.language_id = '". (int)$language_id ."'";

   $product_info_query = tep_db_query($sql);
   $product_info = tep_db_fetch_array($product_info_query);
   $pfs->addPriceBreakData(tep_get_prid($product_id), $product_info);
    }
    $this->parse($product_info);

    return $product_info;
  }
      
  function computePrice($qty)
  {
      $qty = $this->adjustQty($qty);

      // Compute base price, taking into account the possibility of a special
      $price = ($this->hasSpecialPrice === TRUE) ? $this->specialPrice : $this->thePrice;

      for ($i=1; $i<=8; $i++)
            if (($this->quantity[$i] > 0) && ($qty >= $this->quantity[$i]))
                  $price = $this->price[$i];

      return $price;
  }

  function adjustQty($qty) {
      // Force QTY_BLOCKS granularity
      $qb = $this->getQtyBlocks();
      if ($qty < 1)
            $qty = 1;

      if ($qb >= 1)
      {
            if ($qty < $qb)
                  $qty = $qb;

            if (($qty % $qb) != 0)
                  $qty += ($qb - ($qty % $qb));
      }
      return $qty;
  }

  function getQtyBlocks() {
    return $this->qtyBlocks;
  }

  function getPrice() {
    return $this->thePrice;
  }

  function getLowPrice() {
    return $this->lowPrice;
  }

  function getHiPrice() {
    return $this->hiPrice;
  }

  function hasSpecialPrice() {
    return $this->hasSpecialPrice;
  }

  function hasQuantityPrice() {
    return $this->hasQuantityPrice;
  }

  function getPriceString($style='"productPriceInBox"') {
    global $currencies;

    if ($this->hasSpecialPrice == true) {
          $lc_text = '<table align="top" border="1" cellspacing="0" cellpadding="0">';
        $lc_text .= '<tr><td align="center" class=' . $style. ' colspan="2">';
            $lc_text .= '&nbsp;<s>'
            . $currencies->display_price($this->thePrice,
                             tep_get_tax_rate($this->taxClass))
            . '</s>&nbsp;&nbsp;<span class="productSpecialPrice">'
            . $currencies->display_price($this->specialPrice,
                             tep_get_tax_rate($this->taxClass))
            . '</span>&nbsp;'
            .'</td></tr>';
    }
    else
    {
            $lc_text = '<table align="top" border="0" cellspacing="0" cellpadding="4">';
            $lc_text .= '<tr><td align="center" class=' . $style. ' colspan="2"></td></tr>';
    }
      // If you want to change the format of the price/quantity table
      // displayed on the product information page, here is where you do it.

//I Need to call to the table to fetch the customers id and their associated discount rate here

    if($this->hasQuantityPrice == true) {
            for($i=1; $i<=1; $i++) {
                  if($this->quantity[$i] > 0) {
                        $lc_text .= '<tr><td class='.$style.'>'
                        . $this->quantity[1]
                        .'x (Half Boxes)</td><td class='.$style.'>'
                        . $currencies->display_price($this->price[$i],
                        tep_get_tax_rate($this->taxClass))
                        .' each</td><tr><td class='.$style.'>'
                        . $this->quantity[2]
                        .'x (Full Boxes)</td><td class='.$style.'>'
                        . $currencies->display_price($this->price[2],
                        tep_get_tax_rate($this->taxClass))
                        .' each</td></tr></tr>';
                  }
            }


            $lc_text .= '</table>';

      }
      else {
            if ($this->hasSpecialPrice == true) {
                  $lc_text = '&nbsp;<s>'
                    . $currencies->display_price($this->thePrice, tep_get_tax_rate($this->taxClass))
                    . '</s>&nbsp;&nbsp;<span class="productSpecialPrice">'
                    . $currencies->display_price($this->specialPrice, tep_get_tax_rate($this->taxClass))
                    . '</span>&nbsp;';
            }
            else {
                  $lc_text = '&nbsp;'
                    . $currencies->display_price($this->thePrice,
                               tep_get_tax_rate($this->taxClass))
                    . '&nbsp;';
            }
            }

    return $lc_text;
  }

  function getPriceStringShort() {
    global $currencies;

    if ($this->hasSpecialPrice == true) {
      $lc_text = '&nbsp;<s>'
      . $currencies->display_price($this->thePrice,
                             tep_get_tax_rate($this->taxClass))
      . '</s>&nbsp;&nbsp;<span class="productSpecialPrice">'
      . $currencies->display_price($this->specialPrice,
                             tep_get_tax_rate($this->taxClass))
      . '</span>&nbsp;';
    }
    else {
      if($this->hasQuantityPrice == true) {
      $lc_text = '&nbsp;'
        . $currencies->display_price($this->lowPrice,
                               tep_get_tax_rate($this->taxClass))
        . ' - '
        . $currencies->display_price($this->hiPrice,
                               tep_get_tax_rate($this->taxClass))
        . '&nbsp;';
      }
      else {
      $lc_text = '&nbsp;'
        . $currencies->display_price($this->thePrice,
                               tep_get_tax_rate($this->taxClass))
        . '&nbsp;';
      }
    }
    return $lc_text;
  }
}
?>

Start Free Trial
[+][-]11.13.2007 at 07:12PM PST, ID: 20277391

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 07:44PM PST, ID: 20277505

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 07:47PM PST, ID: 20277518

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 07:57PM PST, ID: 20277552

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 08:00PM PST, ID: 20277560

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 08:12PM PST, ID: 20277603

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 08:16PM PST, ID: 20277614

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 09:07PM PST, ID: 20277782

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.13.2007 at 10:55PM PST, ID: 20278051

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 10:48AM PST, ID: 20282499

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 10:51AM PST, ID: 20282533

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 11:00AM PST, ID: 20282638

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 11:17AM PST, ID: 20282790

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 12:07PM PST, ID: 20283248

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 12:15PM PST, ID: 20283318

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 07:34PM PST, ID: 20286305

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 09:04PM PST, ID: 20286961

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 09:09PM PST, ID: 20286990

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 09:27PM PST, ID: 20287060

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.14.2007 at 09:41PM PST, ID: 20287128

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.15.2007 at 12:47AM PST, ID: 20287676

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.15.2007 at 12:34PM PST, ID: 20292163

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 01:30AM PST, ID: 20297036

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 12:48PM PST, ID: 20301384

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 01:53PM PST, ID: 20301836

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 06:07PM PST, ID: 20302956

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 07:06PM PST, ID: 20303091

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 07:41PM PST, ID: 20303148

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 07:42PM PST, ID: 20303150

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 08:07PM PST, ID: 20303177

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 08:12PM PST, ID: 20303182

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 08:24PM PST, ID: 20303207

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 08:29PM PST, ID: 20303221

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 08:45PM PST, ID: 20303243

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 08:48PM PST, ID: 20303250

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 08:54PM PST, ID: 20303273

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 09:14PM PST, ID: 20303307

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 09:15PM PST, ID: 20303308

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 09:16PM PST, ID: 20303310

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 09:17PM PST, ID: 20303313

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 09:18PM PST, ID: 20303316

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 09:20PM PST, ID: 20303323

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]11.16.2007 at 09:27PM PST, ID: 20303338

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]09.24.2008 at 11:43AM PDT, ID: 22562714

View this solution now by starting your 7-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

 

About this solution

Zones: PHP and Databases, PHP Scripting Language
Tags: display_price, join, left
Sign Up Now!
Solution Provided By: twistedindustries
Participating Experts: 1
Solution Grade: A
 
 
 
Loading Advertisement...
<