Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

$this->attributes_price($products_id)


tedbooks

Recommended Posts

i have $this->attributes_price($products_id) in the shopping cart class

i wanted to know where is it coming from so i can modify its value

 

 

$this means this class so it calls the function attributes_price declared within this class by stating $this->attributes_price()

Treasurer MFC

Link to comment
Share on other sites

ok thanks for the quick response. I was trying to give the ability to offer free attributes

 //added this line to get the number of free attributes offer with each product
$free_query = tep_db_query("select products_model,products_free_options from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
         $free_result = tep_db_fetch_array($free_query);

//rmh M-S_pricing end
         $this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count; //rmh M-S_ccgv
         $this->weight_virtual += ($qty * $products_weight) * $no_count; //rmh M-S_ccgv
         $this->total += tep_add_tax($products_price, $products_tax) * $qty;
         $this->weight += ($qty * $products_weight);
       }


// attributes price
$z=0;
       if (isset($this->contents[$products_id]['attributes'])) {
         reset($this->contents[$products_id]['attributes']);
         while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$z+=1;
//rmh M-S_attrib edited next line

           $attribute_price_query = tep_db_query("select options_values_price, price_prefix, options_values_weight from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
           $attribute_price = tep_db_fetch_array($attribute_price_query);
           if ($attribute_price['price_prefix'] == '+') {
//look here i added the if statment to give the free options
       if($free_result['products_free_options']<$z)      $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
//rmh M-S_attrib begin
           if(!empty($attribute_price['options_values_weight'])) {
          	 $this->weight += ($qty * $attribute_price['options_values_weight']);
           }
//rmh M-S_attrib end
         }
       }
     }
   }
    //   $z=0;
   function attributes_price($products_id) {
     $attributes_price = 0;



     if (isset($this->contents[$products_id]['attributes'])) {
    $z=0;
       reset($this->contents[$products_id]['attributes']);
       while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
         $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" .(int)$value  . "'");
         $attribute_price = tep_db_fetch_array($attribute_price_query);
            $z+=1;
   if ($attribute_price['price_prefix'] == '+') {
      //look here i made this condition to give the free options
      if($free_result['products_free_options']<$z)  $attributes_price += $attribute_price['options_values_price'];
         } else {
           $attributes_price -= $attribute_price['options_values_price'];
         }
       }
     }

     return $attributes_price;
   }

   function get_products() {
     global $languages_id;

     if (!is_array($this->contents)) return false;

     $pf = new PriceFormatter; //rmh M-S_pricing
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
//rmh M-S_pricing begin

       if ($products = $pf->loadProduct($products_id, $languages_id)) {
         $products_price = $pf->computePrice($this->contents[$products_id]['qty']);
//rmh M-S_pricing end
         $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
                                   'price' => $products_price,
                                   'quantity' => $this->contents[$products_id]['qty'],
                                   'weight' => $products['products_weight'],
                                   'distributors_id' => $products['distributors_id'],  //rmh M-S_multi-stores
                                  //look here in the next line the price of the attributes is added but my changes doesn't change its value'
    'final_price' => ($products_price + 1000+$this->attributes_price($products_id)),
                                   'tax_class_id' => $products['products_tax_class_id'],
                              'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
                                   'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));
}
     }

     return $products_array;
   }

i have made some changes to do free attributes

i get the correct price to show in the shopping cart box but not from the function any idea?!!!!

Link to comment
Share on other sites

ok thanks for the quick response. I was trying to give the ability to offer free attributes
 //added this line to get the number of free attributes offer with each product
$free_query = tep_db_query("select products_model,products_free_options from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
         $free_result = tep_db_fetch_array($free_query);

//rmh M-S_pricing end
         $this->total_virtual += tep_add_tax($products_price, $products_tax) * $qty * $no_count; //rmh M-S_ccgv
         $this->weight_virtual += ($qty * $products_weight) * $no_count; //rmh M-S_ccgv
         $this->total += tep_add_tax($products_price, $products_tax) * $qty;
         $this->weight += ($qty * $products_weight);
       }
// attributes price
$z=0;
       if (isset($this->contents[$products_id]['attributes'])) {
         reset($this->contents[$products_id]['attributes']);
         while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
$z+=1;
//rmh M-S_attrib edited next line

           $attribute_price_query = tep_db_query("select options_values_price, price_prefix, options_values_weight from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
           $attribute_price = tep_db_fetch_array($attribute_price_query);
           if ($attribute_price['price_prefix'] == '+') {
//look here i added the if statment to give the free options
       if($free_result['products_free_options']<$z)      $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
//rmh M-S_attrib begin
           if(!empty($attribute_price['options_values_weight'])) {
          	 $this->weight += ($qty * $attribute_price['options_values_weight']);
           }
//rmh M-S_attrib end
         }
       }
     }
   }
    //   $z=0;
   function attributes_price($products_id) {
     $attributes_price = 0;
     if (isset($this->contents[$products_id]['attributes'])) {
    $z=0;
       reset($this->contents[$products_id]['attributes']);
       while (list($option, $value) = each($this->contents[$products_id]['attributes'])) {
         $attribute_price_query = tep_db_query("select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$products_id . "' and options_id = '" . (int)$option . "' and options_values_id = '" .(int)$value  . "'");
         $attribute_price = tep_db_fetch_array($attribute_price_query);
            $z+=1;
   if ($attribute_price['price_prefix'] == '+') {
      //look here i made this condition to give the free options
      if($free_result['products_free_options']<$z)  $attributes_price += $attribute_price['options_values_price'];
         } else {
           $attributes_price -= $attribute_price['options_values_price'];
         }
       }
     }

     return $attributes_price;
   }

   function get_products() {
     global $languages_id;

     if (!is_array($this->contents)) return false;

     $pf = new PriceFormatter; //rmh M-S_pricing
     $products_array = array();
     reset($this->contents);
     while (list($products_id, ) = each($this->contents)) {
//rmh M-S_pricing begin

       if ($products = $pf->loadProduct($products_id, $languages_id)) {
         $products_price = $pf->computePrice($this->contents[$products_id]['qty']);
//rmh M-S_pricing end
         $products_array[] = array('id' => $products_id,
                                   'name' => $products['products_name'],
                                   'model' => $products['products_model'],
                                   'image' => $products['products_image'],
                                   'price' => $products_price,
                                   'quantity' => $this->contents[$products_id]['qty'],
                                   'weight' => $products['products_weight'],
                                   'distributors_id' => $products['distributors_id'],  //rmh M-S_multi-stores
                                  //look here in the next line the price of the attributes is added but my changes doesn't change its value'
    'final_price' => ($products_price + 1000+$this->attributes_price($products_id)),
                                   'tax_class_id' => $products['products_tax_class_id'],
                              'attributes' => (isset($this->contents[$products_id]['attributes']) ? $this->contents[$products_id]['attributes'] : ''),
                                   'attributes_values' => (isset($this->contents[$products_id]['attributes_values']) ? $this->contents[$products_id]['attributes_values'] : ''));
}
     }

     return $products_array;
   }

i have made some changes to do free attributes

i get the correct price to show in the shopping cart box but not from the function any idea?!!!!

 

 

I would echo out the various variables:

 

$z and $free_result['products_free_options'] in the loop, see how they compare.

Treasurer MFC

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...