Jump to content
joekushner

Actual Attribute Price V1.0

Recommended Posts

I was able to fix the problem of the attribute item being added to the product price in the product details and totals of checkout_confirmation.php for the ActualAttributesPrices_refreshed contrib.

 

I updated two files.

 

/////////// FIRST FILE UPDATED ///////////////

In the first file I updated the function "attributes_price()" in catalog\includes\classes\shopping_cart.php at approx line 293 (see my code at the bottom of this post):

 

Updates to the function:

My new function now accepts a second variable (product price $prod_price) which is then subtracted from the attribute price if the price_prefix == '' **code below

 

This is what step 2 of the AAP_Install.txt instructions for the ActualAttributesPrices_refreshed contrib said to do but it didn't work for me so (DONT DO THIS):

DO THIS TO catalog\includes\classes\shopping_cart.php

This is the new code I used to replace the instructions above:

//PHPMOM.COM AAP

function attributes_price($products_id, $prod_price) {

$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'];

} elseif ($attribute_price['price_prefix'] == '-') {

$attributes_price -= $attribute_price['options_values_price'];

} elseif ($attribute_price['price_prefix'] == '') {

$attributes_price += $attribute_price['options_values_price'] - $prod_price;

}

}

}

 

return $attributes_price;

}

 

/////////// SECOND FILE UPDATED ///////////////

I made 1 update to the array in catalog\includes\classes\order.php:

My update to the array now passes a second variable (product price $prod_price) into the updated function **code below

 

There were no instructions in the original install document for this

 

DO THIS TO catalog\includes\classes\order.php

This is the updated line of code I used for the second file catalog\includes\classes\order.php:

SEARCH FOR THIS

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

 

REPLACE WITH THIS

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id'],$products[$i]['price']),

It seems to work fine for me now. Let me know if you find any bugs.

Darren

 

hi Darren...

 

Thanks for the fix, unfortunatly it didn't work for me... I think I followed everything correctly...

When I add something to the shopping cart, I get this error:

 

Warning: Missing argument 2 for attributes_price() in /.../catalog/includes/classes/shopping_cart.php on line 376

 

Line 376 in my shopping_cart.php is:

 

function attributes_price($products_id, $prod_price) {

 

Any ideas?

 

Thanks,

~Barbara~

Share this post


Link to post
Share on other sites

While I'm here...

 

I was just wondering if any-one's got AAP working with Easy Populate??? I'm having trouble understanding what I'm supposed to modify to make it work, does anyone have any pointers? Thanks

 

~Barbara~

Share this post


Link to post
Share on other sites
hi Darren...

 

Thanks for the fix, unfortunatly it didn't work for me... I think I followed everything correctly...

When I add something to the shopping cart, I get this error:

 

Warning: Missing argument 2 for attributes_price() in /.../catalog/includes/classes/shopping_cart.php on line 376

 

Line 376 in my shopping_cart.php is:

 

function attributes_price($products_id, $prod_price) {

 

Any ideas?

 

Thanks,

~Barbara~

 

Barbara,

 

Do a find(search) on your code for:

final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

 

Only update the files that ARE NOT in the ADMIN section of the site, since I did not update the similar function in the admin files.

 

Replace the lines of code you find from your above search, with this line:

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id'],$products[$i]['price']),

 

Let me know what happens.

darren

Share this post


Link to post
Share on other sites
Barbara,

 

Do a find(search) on your code for:

final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

 

Only update the files that ARE NOT in the ADMIN section of the site, since I did not update the similar function in the admin files.

 

Replace the lines of code you find from your above search, with this line:

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id'],$products[$i]['price']),

 

Let me know what happens.

darren

 

Darren,

 

I tried changing the above code (to 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id'],$products[$i]['price']),), which works fine in that I don't get any errors. However, I still have the old problem with AAP, in that it adds the base price and the new price together. When I try changing the code in shopping_cart.php, the error message (as before) appears.

 

~Barbara~

Share this post


Link to post
Share on other sites
Darren,

 

I tried changing the above code (to 'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id'],$products[$i]['price']),), which works fine in that I don't get any errors. However, I still have the old problem with AAP, in that it adds the base price and the new price together. When I try changing the code in shopping_cart.php, the error message (as before) appears.

 

~Barbara~

I just found this line in my shopping_cart.php... Does it need to be changed?

 

'final_price' => ($products_price + $this->attributes_price($products_id)), (line 492)

Share this post


Link to post
Share on other sites
I just found this line in my shopping_cart.php... Does it need to be changed?

 

'final_price' => ($products_price + $this->attributes_price($products_id)), (line 492)

 

Don't change that line, keep it the way it is.

 

I'd like to see your the code for your function. Can you send me the code snippet for the function that looks like this:

function attributes_price($products_id, $prod_price) {

Share this post


Link to post
Share on other sites
Don't change that line, keep it the way it is.

 

I'd like to see your the code for your function. Can you send me the code snippet for the function that looks like this:

function attributes_price($products_id, $prod_price) {

 

Sorry - you wanted that from includes/classes/shopping_cart.php, right?

 

This is what I have:

function attributes_price($products_id, $prod_price) {
$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'];
} elseif ($attribute_price['price_prefix'] == '-') {
$attributes_price -= $attribute_price['options_values_price'];
} elseif ($attribute_price['price_prefix'] == '') {
$attributes_price += $attribute_price['options_values_price'] - $prod_price;
}
}
}

return $attributes_price;
}

Edited by bobsi18

Share this post


Link to post
Share on other sites
Sorry - you wanted that from includes/classes/shopping_cart.php, right?

 

This is what I have:

function attributes_price($products_id, $prod_price) {
$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'];
} elseif ($attribute_price['price_prefix'] == '-') {
$attributes_price -= $attribute_price['options_values_price'];
} elseif ($attribute_price['price_prefix'] == '') {
$attributes_price += $attribute_price['options_values_price'] - $prod_price;
}
}
}

return $attributes_price;
}

 

Barbara,

What is the prefix (-,+ or '') for the attribute that you are having trouble with?

Share this post


Link to post
Share on other sites
Barbara,

What is the prefix (-,+ or '') for the attribute that you are having trouble with?

It's both the - and + that I'm having probs with :(

At this stage I've taken it off again, I might try loading up an earlier version soon, when I get closer to having my site done. Can anyone suggest an earlier, 'bug free' version?

 

Thanks

~Barbara~

Share this post


Link to post
Share on other sites

Hi there... I'm closer to going live and am back working on trying to get AAP working - I kow there are people out there using it - what version are you using??? I think it may be a case of 'downgrading', I'm just not sure which version to change to, as the latest isn't working for me...

 

So - what version of AAP are you successfully using???

 

Thanks,

~Barbara~

Share this post


Link to post
Share on other sites
Hi there... I'm closer to going live and am back working on trying to get AAP working - I kow there are people out there using it - what version are you using??? I think it may be a case of 'downgrading', I'm just not sure which version to change to, as the latest isn't working for me...

 

So - what version of AAP are you successfully using???

 

Thanks,

~Barbara~

 

have you ever seen someone jumping from the rooves cause their oscommerce code is working?!!! I found the error, was a mistake on my part:

-- five ------------------------------------------------------------------------
Same File:
FIND:

								'final_price' => ($products_price + $this->attributes_price($products_id)),

CHANGE TO:

								'final_price' => ($products_price + $attributes_price),
								'attributes_price' => $attributes_price, //phpmom.com//aap

--------------------------------------------------------------------------------
IF you have the customer pricing contribution,
Change:

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

To:

'attributes_price'=>$products[$i]['attributes_price'],
'final_price' => $products[$i]['final_price'], //phpmom.com//aap

--------------------------------------------------------------------------------
For customer group pricing only:
Change:

'final_price' => $orders_customers['customers_group_price'] + $cart->attributes_price($products[$i]['id']));

To:

'attributes_price'=>$products[$i]['attributes_price'],
'final_price' => $products[$i]['final_price'], //phpmom.com//aap

================================================================================

I missed a part of the code out, now it's (fingers crosses) working perfectly... Thanks for your help earlier this year, deeman001!

 

:D :D :D :D :D ~Barbara~

Share this post


Link to post
Share on other sites

I have installed this mod and something has gone crazy. If you go to my store, www.shop.tlsc1.com you will find that I am still finishing a few things up. Heres my problem with this mod.

 

When a person addes a product to their cart, it costs x dollars. Lets make x 10 dollars for this example. Well instead of getting the x, they wanted the attribute y. So, since y is going to cost them 2 more dollars than x, the total cost is 12 dollars. When they go to check out, it says 12 dollars as the cost, plust shipping and any tax. As you continue through the checkout process, you get to the end where it says final cost. Instead of being 12 dollars + tax and shipping, its 22 dollars + tax and shipping. Its adding the orignal 10 dollar price, plust saying the attribute is an extra 12 when in reality i want it only to cost a total of 12 dollars. What have I done wrong and how can I fix htis? any help is greatly appreciated... this is setting me back huge : (

Share this post


Link to post
Share on other sites

"This allows for the attribute price to replace the product price

'0' values allowed"

 

found this in the readme... but where do I change this setting? Sounds Like what I need?

Share this post


Link to post
Share on other sites
I have tried EVERY version of this contrib and NONE of them work for me, including EVERY modification post in this thread. No matter how hard I tried, the best it can get is to show the actual price in the option dropdown menu of the product info page, and the check out page as well. But when it goes to the order confirm page, the price is WRONG!!!!!

 

I swith to the contrib http://www.oscommerce.com/community/contributions,2487 and that one works!!!

 

So if you only want to show the actual price in option dropdown list of the product info page, the above one is much easier and stable.

 

Thank you AlexStudio - I've been trying a bunch of different things and wasn't getting the results I needed but the contrib you suggested worked immediately and very very easy to install - thank you very much for mentioning it in this thread my friend - you saved my sorry rear!!!

 

All the best

Share this post


Link to post
Share on other sites

I have recently been having a problem with my shopping cart and attributes not going to the cart, so I started uninstalling contributes to find the conflict. I had installed this contribution some time ago, I do not remember if I updated the sql with this or not:

UPDATE products_attributes
LEFT JOIN products ON products.products_id=products_attributes.products_id
SET products_attributes.options_values_price=products.products_price + products_attributes.options_values_price, products_attributes.price_prefix = NULL
WHERE products_attributes.price_prefix = "+";

UPDATE products_attributes
LEFT JOIN products ON products.products_id=products_attributes.products_id
SET products_attributes.options_values_price=products.products_price - products_attributes.options_values_price, products_attributes.price_prefix = NULL
WHERE products_attributes.price_prefix = "-";

 

I searced mysql and I cannot find anything remotely close to those updates, Im asking if there was a way I could tell where to find these and if it is possible to edit it back to osc standard so I can finish my quest to my error.

 

Thanks

Share this post


Link to post
Share on other sites

Thanks for this contribution Hadir, I was able to get it installed and working in no time.

 

Does anyone have a mod that allows individual specials prices to be assigned to each option? Currently I can only set the special on the base item and change the other option prices manually, but you lose the original prices doing this.

Edited by spent

Share this post


Link to post
Share on other sites

Actually I spoke too soon, it isn't working ALL fine. I'm getting the doubling thing on my checkout page.

 

The fix for it says:

Find the following code around line 230

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

Change it to:

'final_price' => $products[$i]['final_price'],

 

but in my shopping_cart.php it doesn't have that line, it's got:

'final_price' => ($products_price + $attributes_price),

'attributes_price' => $attributes_price, //phpmom.com//aap

 

Can anyone shed some light on how to fix it?

Share this post


Link to post
Share on other sites

I have been playing around with the code in shopping_cart.php and only managed to get either the cart total working with checkout total broken or checkout total working with the cart total broken.

 

Then I decided to turn my attention to includes\classes\order.php and quickly found a simple fix to the problem.

 

All you have to do is find the following line:

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

 

and change it to:

'final_price' => $cart->attributes_price($products[$i]['id']),

Share this post


Link to post
Share on other sites

I installed the order.php fix, and my checkout now works fine.

 

But the shipping cart subtotal still says whatever the base price for the product is.,

 

For instance, if I have a product with a base price of 36, and the next size up is 77, it displays nicely now (without the prefix). I like that. Checkout is nice; if they choose the larger option, checkout says 77, and the shipping is added in ... perfect.

 

But the shopping cart still says 36. If you go to shopping_cart.php it shows the large option for 77 dollars in the cart, and beneath that, it says "Sub Total: $36.00' ..... but above that it says $77.

 

Does anyone have a solution to this? It'd be highly appreciated. Thanks ....


Jason

 

Simple 1-2-3 Intructions on how to get, install and configure SSL

 

The Google Sandbox explained

 

Simple to follow instructions on how to change the look of your OSC

 

How To Make A Horrible OSC Website

 

my toolbox: All things WordPress-related - All things Adobe-related - PHP Designer 2007 - Codecanyon Junkie - Crimson Editor - Winmerge - phpMyAdmin - WS_FTP

 

my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...

Share this post


Link to post
Share on other sites

I don't put two questions in one post, so here's another. In the product_info page, it displays my attributes like this:

2 feet($36.00)

4 feet($77.00)

6 feet($113.00)

8 feet($150.00)

 

I'd like to display the product attributes like this:

2 feet ($36.00)

4 feet ($77.00)

6 feet ($113.00)

8 feet ($150.00)

 

Anyone know how I can get that space in between the attribute and the price? Thanks all.


Jason

 

Simple 1-2-3 Intructions on how to get, install and configure SSL

 

The Google Sandbox explained

 

Simple to follow instructions on how to change the look of your OSC

 

How To Make A Horrible OSC Website

 

my toolbox: All things WordPress-related - All things Adobe-related - PHP Designer 2007 - Codecanyon Junkie - Crimson Editor - Winmerge - phpMyAdmin - WS_FTP

 

my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...

Share this post


Link to post
Share on other sites
Actually I spoke too soon, it isn't working ALL fine. I'm getting the doubling thing on my checkout page.

 

The fix for it says:

Find the following code around line 230

'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),

Change it to:

'final_price' => $products[$i]['final_price'],

 

but in my shopping_cart.php it doesn't have that line, it's got:

'final_price' => ($products_price + $attributes_price),

'attributes_price' => $attributes_price, //phpmom.com//aap

 

Can anyone shed some light on how to fix it?

 

You have to amend catalog/includes/classes/order.php, not shopping_cart.php. You're looking at the wrong file.


Jason

 

Simple 1-2-3 Intructions on how to get, install and configure SSL

 

The Google Sandbox explained

 

Simple to follow instructions on how to change the look of your OSC

 

How To Make A Horrible OSC Website

 

my toolbox: All things WordPress-related - All things Adobe-related - PHP Designer 2007 - Codecanyon Junkie - Crimson Editor - Winmerge - phpMyAdmin - WS_FTP

 

my installed contributions: Category Banners, File Upload feature-.77, Header Tags, Sort_Product_Attributes_1, XSellv2.3, Price Break 1.11.2, wishlist 3.5, rollover_category_images_v1.2, Short_Description_v2.1, UPSXML_v1_2_3, quickbooks qbi_v2_10, allprods v4.4, Mouseover-effect for image-buttons 1.0, Ultimate_SEO, AAP 1.41, Auto Select State Value, Fast Easy Checkout, Dynamic SiteMap v2.0, Image Magic, Links Manager 1.14, Featured Products, Customer Testimonials, Article Manager, FAQ System, and I'm sure more ...

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

×