Jump to content
joekushner

Actual Attribute Price V1.0

Recommended Posts

yes, actually i'm the one that made it.

 

it will work just how you want. i have a mix of both on my site if you would like to see it in action.

 

www.moto-works.com/catalog

 

thanks for the interest

Share this post


Link to post
Share on other sites
yes, actually i'm the one that made it.

 

it will work just how you want. i have a mix of both on my site if you would like to see it in action.

 

www.moto-works.com/catalog

 

thanks for the interest

it dosent work both ways :(

 

at least it's not for me... but i was looking at the code...

 

is there a reason why its so many lines of code? here's what i figured out

I put this in shopping_cart.php just added an elseif and the new line for both -- see example

if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else if ($attribute_price['price_prefix'] == '-'){           //changed
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); 
           } else $this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax); //added

 

and that seems to work, except the shopping cart box dosent keep the correctly updated price

Share this post


Link to post
Share on other sites
yes, actually i'm the one that made it.

 

it will work just how you want. i have a mix of both on my site if you would like to see it in action.

 

www.moto-works.com/catalog

 

thanks for the interest

it dosent work both ways :(

 

at least it's not for me... but i was looking at the code...

 

is there a reason why its so many lines of code? here's what i figured out

I put this in shopping_cart.php just added an elseif and the new line for both -- see example

if ($attribute_price['price_prefix'] == '+') {
? ? ? ? ? ? ?$this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
? ? ? ? ? ?} else if ($attribute_price['price_prefix'] == '-'){ ? ? ? ? ? //changed
? ? ? ? ? ? ?$this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); 
? ? ? ? ? ?} else $this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax); //added

 

and that seems to work, except the shopping cart box dosent keep the correctly updated price

I just fixed it..... I cut down on your code drastically

 

general.php stays the same for the function.... but here's the new shopping_cart.php file

 

Original - ~ line 239

if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else {           //changed
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);

 

new

if ($attribute_price['price_prefix'] == '+') {
             $this->total += $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax);
           } else if ($attribute_price['price_prefix'] == '-'){           //changed
             $this->total -= $qty * tep_add_tax($attribute_price['options_values_price'], $products_tax); 
           } else $this->total += $qty * tep_add_tax(tep_adjust_price($attribute_price['options_values_price'], $products_stuff['products_price']), $product_tax);

 

then old ~ line 256

if ($attribute_price['price_prefix'] == '+') {
           $attributes_price += $attribute_price['options_values_price'];
         } else  {
           $attributes_price -= $attribute_price['options_values_price'];

and new

if ($attribute_price['price_prefix'] == '+') {
           $attributes_price += $attribute_price['options_values_price'];
         } else if ($attribute_price['price_prefix'] == '-') {
           $attributes_price -= $attribute_price['options_values_price'];
         } else $attributes_price += tep_adjust_price($attribute_price['options_values_price'], $products_stuff['products_price']);

 

works like a charm

 

just a suggestion to save some lines of code... but an excellent mod however! gave me the ambition to take it apart and figure out how it worked.

Share this post


Link to post
Share on other sites

no the above code still dosent work

 

it seems to have a problem like if i have some selectable options with no price, then one with a price it dosent calculate right

Share this post


Link to post
Share on other sites

if you got this contrib and it's not working properly (which it wont) edit these lines

 

line 250 replace with

if (($price_prefix == '') and ($option_price != 0)) {

 

line 278 replace with

if (($price_prefix == '') and ($option_price != 0)) {

 

and everything will function old way, and this new way

 

enjoy

Share this post


Link to post
Share on other sites

Thanks Joe!

 

You've made the correct changes. I was doing some more tests on this last night and realized what it was doing, but you beat me to the punch.

 

sorry so many lines of code, i'm still rather new to php, so i know there are better ways to do some of the stuff i want to do, but i don't know how.

 

Thanks for the support!

 

(what do you think, should they add this into the next release of OSC?)

Share this post


Link to post
Share on other sites
Thanks Joe!

 

You've made the correct changes. I was doing some more tests on this last night and realized what it was doing, but you beat me to the punch.

 

sorry so many lines of code, i'm still rather new to php, so i know there are better ways to do some of the stuff i want to do, but i don't know how.

 

Thanks for the support!

 

(what do you think, should they add this into the next release of OSC?)

of course! its nice to have more options available, especially one that the code is fairly simple to add another IF statement :)

Share this post


Link to post
Share on other sites

Okay... question for you...

 

Where do I get the shopping_cart.php ... which contains the lines of code that you specified in your posts... the only shopping_cart.php that comes with the distribution does not contain the original code that you need to replace for it to work with the + / - / set price for an attribute....

 

Please let me know.

 

 

Thanks!

Share this post


Link to post
Share on other sites

I already have my store set up and running and want to add this, but with over 60 products and 6 attributes a piece, it will be so time consuming to go back and redo all these....once installing the Actual Price Attribute contribution

 

Is there a contribution that keep the attributes the way they are in the admin but displays the full price in the drop down?

Share this post


Link to post
Share on other sites

at this point i don't think there is.

 

however, with a little bit of messing around in the code, you should be able to do this without too much trouble.

Share this post


Link to post
Share on other sites

This mod is exactly what I need but I can't seem to get it working. Just get a bunch of error messages.

 

I can't just replace files since I've already got so many hacks in place so I've got to copy and paste.

 

Are we supposed to modify pages in admin or catalog?

 

 

includes/classes/shopping_cart.php

Includes/functions/general.php

 

I only see one change in both files. Is this correct or are there more changes that I'm not seeing?

 

Thanks!

Edited by bishop

Share this post


Link to post
Share on other sites

OK I surrender I have spent hours trying to get this to work and just can't seem to get it right. I don't get any errors but if I have a product with two attributes the price is doubled. Click here and add the product to the cart to see what I mean. I am totally lost.

 

Are we supposed to modify pages in admin or catalog?

 

Modify the pages in catalog not admin.

Edited by KMYComput

Share this post


Link to post
Share on other sites

I know I asked this in another thread, but this probably should be the place for it :)

 

I've installed this contrib, and my question is how to you handle displaying of the product price in product_info.php? Example:

 

You have a product that comes in 3 sizes - Size A, B, and C. The product is a different price at each size. I know one way of handling this is to create the product at one size with a price, and then having the other two sizes as attributes and then appearing in the dropdown. Is this the way it should be done? Or could you create the product with a price of $0, and then create it 3 times with the size attributes? I did it this last way, and the drop down and pricing is working right, but then of course a price of $0.00 is displaying on the description, which isn't very clean or nice.

 

Any ideas?

Share this post


Link to post
Share on other sites
This mod is exactly what I need but I can't seem to get it working. Just get a bunch of error messages.

 

I can't just replace files since I've already got so many hacks in place so I've got to copy and paste.

 

Are we supposed to modify pages in admin or catalog?

 

 

includes/classes/shopping_cart.php

Includes/functions/general.php

 

I only see one change in both files. Is this correct or are there more changes that I'm not seeing?

 

Thanks!

I Installed Actual Attributes Price v1.0 and now I get the following error:

 

"Fatal error: Call to undefined function: tep_get_configuration_key_value() in c:\appserv\www\catalog\includes\classes\shipping.php on line 34"

 

After clicking on check out I get this error also:

 

"Fatal error: Call to undefined function: tep_get_configuration_key_value() in c:\appserv\www\catalog\checkout_shipping.php on line 22"

 

Has anyone installed this contrib without any errors? :angry: If so, maybe someone could post the fix here so those of use that have not got the bug(s) worked out can get it working? :(

 

Michael


Michael

Share this post


Link to post
Share on other sites

Hi,

 

Which version did you install? and what kind of version of OSC are you using? Sounds a version conflict to me. I have the contrib installed and its working fine. The only problem i had was with attributes that has 0,- as value (like colour). When i dont use a prefix he adds up the initianal value in the sub-total list. I couldnt fix it properly but fixed it use the + prefix. So know he adds up the zero which is no problem in the end.

Share this post


Link to post
Share on other sites
You have a product that comes in 3 sizes - Size A, B, and C.  The product is a different price at each size.  I know one way of handling this is to create the product at one size with a price, and then having the other two sizes as attributes and then appearing in the dropdown.  Is this the way it should be done?  Or could you create the product with a price of $0, and then create it 3 times with the size attributes?  I did it this last way, and the drop down and pricing is working right, but then of course a price of $0.00 is displaying on the description, which isn't very clean or nice.

 

Why couldn't you create it with the base price (or the minimal price) and then just have all the attributes listed? Wouldn't it come out something like the following:

 

Options:

AttributeA

AttributeB ($X)

AttributeC ($Y)

 

I mean, OSC already allows you to have attributes that don't change the price... so why would the "actual price" module make it so that you can't still have an attribute with no modification in price? The "actual price" would just be the original price of the item! Or wouldn't it?

Share this post


Link to post
Share on other sites

From my understanding we still have to have a base price $X, and if you have 2 attributes you would have variables $A and $B.

 

Let's say $X = 5.00, $A = 2.00 and $B=3.00

 

With this contribution installed, the shoppers wouls see:

 

5.00

7.00

8.00

 

 

Whereas w/o the contribution it will show:

 

5.00

+2.00

+3.00

 

 

My question is whether or not we can enter the actual value of the product with a certain attribute rather than the difference. ALso, would this work with Easy Populate?

Share this post


Link to post
Share on other sites

When you install the module, you will see a list of all the attributes at the bottom of the prodcut entry page. I will get a screenshot for you if you like.

 

Basically, if the "base" price was $5, then that would be that.

If choosing attribute a adds $2, you would need to enter "$7" in the price. if choosing attribute b adds $3, you would need to enter "$8" in the price. You could not combine the two attributes to make something costing $10 with this modification, but I don't really think that's what you are doing.

 

You might also have to add a "Base" or "Stock" or blank attribute ($blank) which has no price modification -- otherwise when trying to enter the item in the shopping cart you may inadvertently be forced to pick one of the attributes instead of the base.

 

If you poke around my store (www.festivegarage.com/store) you might see a little bit about how this mod works. The safety section with the roll bar product has + prices, and all the rest of the items in the store have fixed option prices.

 

Sorry if this is difficult to understand, I'm a nerd.

Share this post


Link to post
Share on other sites

Hi Thoraxe,

 

Thanks for asnwering my question. So let me confirm this... the Actual Attribute Price V1.0 will allow the admin of the store to enter in the actual price of the product along with the attribute right?

 

I checked out your website (nice site BTW) and I can see that from the customer's point of view if a digital camera is $200 and the digital camera with an additional battery is $230.

 

What I want to confirm is that when the admins does enter the product, instead of entering the base price and the difference of $30 in the attribute section you can just enter in $230 right?

 

Another questly I have is will this work with Easy Populate?

 

Lastly, how does this mod affect the existing products in the store?

Share this post


Link to post
Share on other sites

importhookup,

 

1) You can enter the price by either means. If you enter just $230 and include no modifier (+/-) then you will see $230. If you enter + and $30, you will see +$30.

2) I don't really know anything about easy populate, I've never used it :(

3) I installed the mod and did not see any adverse affects to any products in the store. I went back and edited the ones I wanted to have fixed prices (the clutches) and left the ones that needed attribute-affected prices (the roll bars).

 

Thanks for the compliments!

Share this post


Link to post
Share on other sites

Hi Thoraxe,

 

Thanks for getting back to me. After reading all the information that came with the download I realized that I had all my questions answered. I'm still quite new to oscommerce so I'm finally getting a hang of how things work around here. Thanks for being so patient and answering my questions.

 

This is a great mod BTW, especially for people who get a list of items from their distributors in excel format. For example, you can run excel and get a list of prices at 10% (*.90) and enter that number in the attribute rather than finding the difference amongst the items.

 

Below is the code from Easy Attribute (great contribution btw). I'm going to take a look at it and see if I'm able to modify it to wrok with actual attribute price.

 

  // VJ product attribs begin
 if (isset($v_attribute_options_id_1)){
	 $attribute_rows = 1; // master row count

	 $languages = tep_get_languages();

	 // product options count
	 $attribute_options_count = 1;
	 $v_attribute_options_id_var = 'v_attribute_options_id_' . $attribute_options_count;

	 while (isset($$v_attribute_options_id_var) && !empty($$v_attribute_options_id_var)) {
   // remove product attribute options linked to this product before proceeding further
   // this is useful for removing attributes linked to a product
   $attributes_clean_query = "delete from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$v_products_id . "' and options_id = '" . (int)$$v_attribute_options_id_var . "'";

   tep_db_query($attributes_clean_query);

   $attribute_options_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$$v_attribute_options_id_var . "'";

   $attribute_options_values = tep_db_query($attribute_options_query);

   // option table update begin
   if ($attribute_rows == 1) {
  	 // insert into options table if no option exists
  	 if (tep_db_num_rows($attribute_options_values) <= 0) {
     for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
    	 $lid = $languages[$i]['id'];

       $v_attribute_options_name_var = 'v_attribute_options_name_' . $attribute_options_count . '_' . $lid;

    	 if (isset($$v_attribute_options_name_var)) {
       $attribute_options_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_options_name_var . "')";

       $attribute_options_insert = tep_db_query($attribute_options_insert_query);
    	 }
     }
  	 } else { // update options table, if options already exists
     for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
    	 $lid = $languages[$i]['id'];

    	 $v_attribute_options_name_var = 'v_attribute_options_name_' . $attribute_options_count . '_' . $lid;

    	 if (isset($$v_attribute_options_name_var)) {
       $attribute_options_update_lang_query = "select products_options_name from " . TABLE_PRODUCTS_OPTIONS . " where products_options_id = '" . (int)$$v_attribute_options_id_var . "' and language_id ='" . (int)$lid . "'";

       $attribute_options_update_lang_values = tep_db_query($attribute_options_update_lang_query);

       // if option name doesn't exist for particular language, insert value
       if (tep_db_num_rows($attribute_options_update_lang_values) <= 0) {
      	 $attribute_options_lang_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS . " (products_options_id, language_id, products_options_name) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_options_name_var . "')";

      	 $attribute_options_lang_insert = tep_db_query($attribute_options_lang_insert_query);
       } else { // if option name exists for particular language, update table
      	 $attribute_options_update_query = "update " . TABLE_PRODUCTS_OPTIONS . " set products_options_name = '" . $$v_attribute_options_name_var . "' where products_options_id ='" . (int)$$v_attribute_options_id_var . "' and language_id = '" . (int)$lid . "'";

      	 $attribute_options_update = tep_db_query($attribute_options_update_query);
       }
    	 }
     }
  	 }
   }
   // option table update end

   // product option values count
   $attribute_values_count = 1;
   $v_attribute_values_id_var = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count;

   while (isset($$v_attribute_values_id_var) && !empty($$v_attribute_values_id_var)) {
  	 $attribute_values_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$$v_attribute_values_id_var . "'";

  	 $attribute_values_values = tep_db_query($attribute_values_query);

  	 // options_values table update begin
  	 if ($attribute_rows == 1) {
     // insert into options_values table if no option exists
     if (tep_db_num_rows($attribute_values_values) <= 0) {
    	 for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
       $lid = $languages[$i]['id'];

       $v_attribute_values_name_var = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid;

       if (isset($$v_attribute_values_name_var)) {
      	 $attribute_values_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$$v_attribute_values_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_values_name_var . "')";

      	 $attribute_values_insert = tep_db_query($attribute_values_insert_query);
       }
    	 }


    	 // insert values to pov2po table
    	 $attribute_values_pov2po_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES_TO_PRODUCTS_OPTIONS . " (products_options_id, products_options_values_id) values ('" . (int)$$v_attribute_options_id_var . "', '" . (int)$$v_attribute_values_id_var . "')";

    	 $attribute_values_pov2po = tep_db_query($attribute_values_pov2po_query);
     } else { // update options table, if options already exists
    	 for ($i=0, $n=sizeof($languages); $i<$n; $i++) {
       $lid = $languages[$i]['id'];

       $v_attribute_values_name_var = 'v_attribute_values_name_' . $attribute_options_count . '_' . $attribute_values_count . '_' . $lid;

       if (isset($$v_attribute_values_name_var)) {
      	 $attribute_values_update_lang_query = "select products_options_values_name from " . TABLE_PRODUCTS_OPTIONS_VALUES . " where products_options_values_id = '" . (int)$$v_attribute_values_id_var . "' and language_id ='" . (int)$lid . "'";

      	 $attribute_values_update_lang_values = tep_db_query($attribute_values_update_lang_query);

      	 // if options_values name doesn't exist for particular language, insert value
      	 if (tep_db_num_rows($attribute_values_update_lang_values) <= 0) {
         $attribute_values_lang_insert_query = "insert into " . TABLE_PRODUCTS_OPTIONS_VALUES . " (products_options_values_id, language_id, products_options_values_name) values ('" . (int)$$v_attribute_values_id_var . "', '" . (int)$lid . "', '" . $$v_attribute_values_name_var . "')";

         $attribute_values_lang_insert = tep_db_query($attribute_values_lang_insert_query);
      	 } else { // if options_values name exists for particular language, update table
         $attribute_values_update_query = "update " . TABLE_PRODUCTS_OPTIONS_VALUES . " set products_options_values_name = '" . $$v_attribute_values_name_var . "' where products_options_values_id ='" . (int)$$v_attribute_values_id_var . "' and language_id = '" . (int)$lid . "'";

         $attribute_values_update = tep_db_query($attribute_values_update_query);
      	 }
       }
    	 }
     }
  	 }
  	 // options_values table update end

  	 // options_values price update begin
     $v_attribute_values_price_var = 'v_attribute_values_price_' . $attribute_options_count . '_' . $attribute_values_count;

  	 if (isset($$v_attribute_values_price_var) && ($$v_attribute_values_price_var != '')) {
     $attribute_prices_query = "select options_values_price, price_prefix from " . TABLE_PRODUCTS_ATTRIBUTES . " where products_id = '" . (int)$v_products_id . "' and options_id ='" . (int)$$v_attribute_options_id_var . "' and options_values_id = '" . (int)$$v_attribute_values_id_var . "'";

     $attribute_prices_values = tep_db_query($attribute_prices_query);
//tim's attribute value fix
     $attribute_values_price_prefix = ($$v_attribute_values_price_var < 0) ? '-' : '+';

     // options_values_prices table update begin
     
     // insert into options_values_prices table if no price exists
     if (tep_db_num_rows($attribute_prices_values) <= 0) {
    	 $attribute_prices_insert_query = "insert into " . TABLE_PRODUCTS_ATTRIBUTES . " (products_id, options_id, options_values_id, options_values_price, price_prefix) values ('" . (int)$v_products_id . "', '" . (int)$$v_attribute_options_id_var . "', '" . (int)$$v_attribute_values_id_var . "', '" . (float)$$v_attribute_values_price_var . "', '" . $attribute_values_price_prefix . "')";

    	 $attribute_prices_insert = tep_db_query($attribute_prices_insert_query);
     } else { // update options table, if options already exists
    	 $attribute_prices_update_query = "update " . TABLE_PRODUCTS_ATTRIBUTES . " set options_values_price = '" . $$v_attribute_values_price_var . "', price_prefix = '" . $attribute_values_price_prefix . "' where products_id = '" . (int)$v_products_id . "' and options_id = '" . (int)$$v_attribute_options_id_var . "' and options_values_id ='" . (int)$$v_attribute_values_id_var . "'";

    	 $attribute_prices_update = tep_db_query($attribute_prices_update_query);
     }
  	 }
  	 // options_values price update end

  	 $attribute_values_count++;
  	 $v_attribute_values_id_var = 'v_attribute_values_id_' . $attribute_options_count . '_' . $attribute_values_count;
   }

   $attribute_options_count++;
   $v_attribute_options_id_var = 'v_attribute_options_id_' . $attribute_options_count;
	 }

	 $attribute_rows++;
 }
 // VJ product attribs end

} else {
 // this record was missing the product_model
 array_walk($items, 'print_el');
 echo "<p class=smallText>No products_model field in record. This line was not imported <br>";
 echo "<br>";
}
// end of row insertion code
}

Share this post


Link to post
Share on other sites

Eveyrthing aside with Esay Populate...

 

I'm having problems with my shopping cart which is showing the base price + double the value of the attribute. For example, if hte base price is $100 and the attribute value is +20, the item in the cart would show $140. Can someone please show me how to fix this problem??

Share this post


Link to post
Share on other sites

I discovered more problems :(

 

When I look in the shopping cart, each individual items listed will show the base price + 2X the attribute value. The subtotal on the other hand, is showing the correct value. However, at the final checkout the final price is the sum of all the base price + 2X the attribute value again! :angry:

 

Sigh... if someone can please help me solve this problem I would greatly appreciate it.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×