Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Help bledning two contributions


Recommended Posts

Hi all,

 

I have tried and tried and tried to work this out and much to my dismay, I just can't and I now have a syntax error I cannot get rid of.

 

I installed the add weights to product attributes contribution and it works fine. I then went ahead and installed the Attribute Pricing Contribution and it didn't work. I started looking through the shopping_cart.php file only to discover that the two contributions use the same string of commands. So basically I had them doubled up. So, deciding to really get into this, I though heck I can figure this out... So now here I am lol.

 

The problem areas are as follows...

 

Attribute weight contribution:

 

// attributes price
// [email protected]/
/ add-weight-to-product-attributes mod:
// added weight to db query        
      if (isset($this->contents[$products_id]['attributes'])) {
         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, 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'] == '+') { 
               $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);            }
             if(!empty($attribute_price['options_values_weight'])) { 
                // [email protected]   
            	// add-weight-to-product-attributes mod:
           	   $this->weight += ($qty * $attribute_price['options_values_weight']);
              } // END if(!empty($attribute_price['options_values_weight'])) { 
        } 
      }
     } 
  } 
    function attributes_price($products_id) { 
      $attributes_price = 0;

     if (isset($this->contents[$products_id]['attributes'])) {
       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);
          if ($attribute_price['price_prefix'] == '+') { 
            $attributes_price += $attribute_price['options_values_price']; 
         } else { 
            $attributes_price -= $attribute_price['options_values_price'];
         } 
      }
     } 
      return $attributes_price;
   }

 

and then the pricing attribute contrib has this:

 

//////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////
// BOF - AAP V1.0 - updated to account for no price prefix to equal actual price/
/ attributes price
       if (isset($this->contents[$products_id]['attributes'])) {
         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)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
           $attribute_price = tep_db_fetch_array($attribute_price_query);
           $price_prefix = $attribute_price['price_prefix'];
           $option_price = $attribute_price['options_values_price'];
             $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
             $products_stuff = tep_db_fetch_array($products_query);
             $products_price = $products_stuff['products_price'];
           if ($price_prefix == '+') { 
          $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
             if ($price_prefix == '-') {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
               if ($price_prefix == '') {
               $this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax);
           }
         } 
      }
     }
   }

// subtotal function for attributes price
   function attributes_price($products_id) {
     $attributes_price = 0;
     if (isset($this->contents[$products_id]['attributes'])) {
       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); 
        $price_prefix = $attribute_price['price_prefix'];
         $option_price = $attribute_price['options_values_price'];
           $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");
           $products_stuff = tep_db_fetch_array($products_query);            $products_price = $products_stuff['products_price'];          if ($price_prefix == '+') {          $attributes_price += $option_price;
         }
           if ($price_prefix == '-') {
           $attributes_price -= $option_price;
         }
             if ($price_prefix == '') {
             $attributes_price += tep_adjust_price($option_price, $products_price); 
        }
       }
     }
     return $attributes_price;
   }
// EOF - AAP V1.0//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

 

I tried to amalgamate them by keeping the common strings (and comparing them to the original file) but I keep getting an error.

 

IF anyone can help me or at least point me in the right direction I would very much appreciate it.

 

Thank you,

Randi

Edited by creationsfromeden
Link to comment
Share on other sites

Apparently I don't know how to post code in this forum... hmmm...

 

I'm fixing it right now, it's not going to be 100% with the spacing, but enough to get the drift. I don't want someone to do it for me, just tell me how...

 

Thank you.

Edited by creationsfromeden
Link to comment
Share on other sites

Okay I found a fix, but I do not understand it... this is what it says to do:

 

FIX to add an attribute's actual weight for checkout and shipping

 

 

 

The only problem with this contribution is that it doesn't account for weights. So I came up with this fix.

What this does is allow you to assign specific weights to each attribute. When you select an attribute product for purchase, that attribute's weight is added to cart (for checkout and shipping purposes) WITHOUT BEING ADDED TO THE PRODUCT'S ORIGINAL WEIGHT!!! The product's base weight is replaced with the weight of the attribute!

 

Before proceeding make sure you already have the Actual Attribute Price mod correctly installed, as this edits one of it's lines of code.

 

STEP 1: Install the contribution: "Add Weight To Product Attributes v0.2"

 

STEP 2: In catalog/classes/shopping_cart.php:

 

Find this line:

 

$this->weight += ($qty * $attribute_price['options_values_weight']);

 

And replace it with this line:

 

$this->weight += ($qty * $attribute_price['options_values_weight'])-($qty * $products_weight);

 

That's it!!

 

 

----------------------------------

Contributed by Philip

[email protected]

 

 

And that's great BUT.... when I install the product weights module (which I had done, then add the Pricing contribution, I have the two parts above that seem to conflict with one another...

 

Does the fix mean, install the weights contribution ad then edit the one line and that is it? Don't worry about installing the pricing one for the shoppingcart file? LOL I think I've stared wayyy too long at his and need a gentle SHOVE in the appropraite direction lol.

Link to comment
Share on other sites

Alrighty, now I have done the following (logically (to me anyway) I think blending the two would look like this...

 

// BOF - AAP V1.0 - updated to account for no price prefix to equal actual price
// attributes price
       if (isset($this->contents[$products_id]['attributes'])) {
         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)$prid . "' and options_id = '" . (int)$option . "' and options_values_id = '" . (int)$value . "'");
           $attribute_price = tep_db_fetch_array($attribute_price_query);
           $price_prefix = $attribute_price['price_prefix'];
           $option_price = $attribute_price['options_values_price'];
             $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");              $products_stuff = tep_db_fetch_array($products_query);
             $products_price = $products_stuff['products_price'];
           if ($price_prefix == '+') {
           $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }              if ($price_prefix == '-') {
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           }
               if ($price_prefix == '') {
               $this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax);
           if(!empty($attribute_price['options_values_weight'])) {
           	// [email protected]
           	// add-weight-to-product-attributes mod:
           	$this->weight += ($qty * $attribute_price['options_values_weight'])-($qty * $products_weight);
           } // END if(!empty($attribute_price['options_values_weight'])) {
         }
       }
     }
   }
// subtotal function for attributes price
   function attributes_price($products_id) {
     $attributes_price = 0;      if (isset($this->contents[$products_id]['attributes'])) {
       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);
         $price_prefix = $attribute_price['price_prefix'];
         $option_price = $attribute_price['options_values_price'];
           $products_query = tep_db_query("select products_price from " . TABLE_PRODUCTS . " where products_id = '" . (int)$products_id . "'");            $products_stuff = tep_db_fetch_array($products_query);
           $products_price = $products_stuff['products_price'];
         if ($price_prefix == '+') {
         $attributes_price += $option_price;
         }
           if ($price_prefix == '-') {
           $attributes_price -= $option_price;
         }
             if ($price_prefix == '') {
             $attributes_price += tep_adjust_price($option_price, $products_price);
         }
       }
     }
     return $attributes_price;
   }
// EOF - AAP V1.0/////////////////////////////////////////////////////////////////////////////////

 

Now I get the Parse Error: Syntax error, unexpected ';', expecting T_OLD_FUNCTION or T_FUNCTION of T_VAR or '}' on line 405 (which is my final ?> and nothing else on the line. So where it is getting the semi colon, I don't know.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...