Community Add-Ons
Actual Attribute Price V1.0
for osCommerce Online Merchant v2.2
This contribution is designed for those of us who would rather use a product attributes actual price rather than use a calculator to figure out the option price.
Example:
--------
Tire A
Price: $84.99
Options: Size 1
Size 2 ($89.99)
Size 3 ($95.99)
Size 4 ($109.99)
Versus
-------
Tire B
Price: $84.99
Options: Size 1
Size 2 ($5.00)
Size 3 ($11.00)
Size 4 ($25.00)
As you can plainly see, it is much easier for a customer to figure out the cost of Tire A Size 4 than it would be for Tire B Size 4.
Installation:
-------------
1. Copy my updated code from:
includes/classes/shopping_cart.php
Includes/functions/general.php
(code is marked by "AAP V1.0")
2. Your are done! Now wasn't that easy?
Using AAP:
----------
It's very simple. When creating a product
attribute, leave the price prefix empty and
insert the price you want to sell the product
for with that attribute. (i.e. Tire A Size 4)
I hope you find this usefull, I know I did.
* This is a complete package *
Updates
+ Added Fix from zeppos
+ Added utility to update all your existing attributes quickly.
+ Added back Compare files for those that know how to use them and know how much time it saves.
+ Cleaned up the code so it actually uses the vars it sets-up.
+ Added required GNU licensing notice.
Discuss: http://forums.oscommerce.com/index.php?showtopic=69543
Just a small correction in both versions 1.5 and 1.6.
in the file includes/classes/shopping_cart.php, the line:
$this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $product_tax);
should be:
$this->total += $qty * tep_add_tax(tep_adjust_price($option_price, $products_price), $products_tax);
(the ONLY thing that changes is the $products_tax at the end of the string, it was typed as "product_tax")
NO FILE UPLOADED.
This is an improvement over 1.5. add better how to install.txt so no one will get lasted in deciphering where to put the code in. Also improved performance and speed for the server use.
I have cleaned up and updated the install file to, hopefully, make this contribution easier to follow along with and install. I have also added screenshots.
All credit goes to the original and contributing authors.
Please feel free to add/modify/update this contribution if you can. Thanks again.
I have noticed that this contribution is scattered so I have just created a working full package,
with all the files without any bugs.
I have added one small change in the admin product_attribute page, to remove the price_prefix
column so that the user enters the actual price of a given attribute without worrying about leaving
the price_prefix column blank
Actual Attribute Price
---------------------------------------
Fix for catalog/includes/classes/order.php
The Checkout Confirmation page in the shopping cart uses the functions from catalog/includes/classes/order.php to gather it's information. It was presenting the wrong price information since order.php was not updated in previous versions of this contribution.
The cart() function in the lower part of the page uses the get_products() function from catalog/includes/classes/shopping_cart.php for all the product and price information for the Checkout Confirmation page.
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'],
This will bring in the correct price information to the Checkout Confirmation page.
This contribution is working well for us now that we fixed this glitch.
In the catalog folder you will find drop-in files for a MS2 fresh install.
You can use a file comparison utility with these files, or follow the included
instructions. (Which have been cleaned up a bit)
What it does:
As coded, this mod will change the attributes coding so that if there is no
prefix added to the attribute price, the dropdown will display the attribute
price with no prefixes, and when the selection is added to the cart, the value
of the attribute will be passed to the shopping cart as the total price.
If there is a prefix, it will still display the attribute price with the prefix,
and the calculation will be applied to the base price in the same manner as it
already does by default.
This works with a combination of prefixed and non-prefixed attributes, as long
as only one attribute is non-prefixed.
Example:
Matrox G400 32MB $499.00
Memory: 16MB (-$10.00)
Model: Deluxe ($609.00)
When the above options are selected, the price of $609.00 will override the
price of $499.00, and $10.00 will be subtracted from $609.00.
See the end of file for a SQL snippet to convert your attributes prices to flat
prices.
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!!
I've tested this in every scenario possible, but there is still a possibility for error.
This fixes the multiple attribute prefix bug.
Read this http://forums.oscommerce.com/index.php?showtopic=69543&view=findpost&p=562891
fix is here
http://forums.oscommerce.com/index.php?showtopic=69543&view=findpost&p=565490
Again this only happens with the above criteria. So if you have it already and it works for you and you know you won't have that problem don't worry about it.
Allows for actual price of product in attribute not just + or -.
When using do not place anything in the prefix (leave it blank) unless you want it added or subtracted. when an attribute does not change the products price do not put '0' in price this will cause the final price to be '$0'.
Forgot to add the new file to the zip. SORRY
Version 1.4 STABLE now on several sites.
This just fixes a typo which caused several errors. There were too many dots '.' in the Advanced method catalog/shopping_cart.php modifictaions.
If you use the Simple and you don't plan on using the advanced method you don't really need this.
Complete Instructions in download.
If you use this and you like it (or don't) please send me an email (in download) or you can comment at this actual attribute topic that was started a while back
http://forums.oscommerce.com/index.php?showtopic=69543
Sorry everyone found another
And no I will not say this is the last one because I jinx it
Anyway got an email telling me the products without an attribute display as
'0' in shopping cart and checkout
I guess everyone was concentrating on whether the script worked with
attributes no one checked without. I didn't..
Here is the fix also attached full changes
SIMPLE
5-in classes/shopping_cart.php above
includes bug fix from 1.3.4 where if there was no attribute product price =
0
$products_array[] = array('id' => $products_i
add
//actual attribute//hadir
if (isset($this->contents[$products_id]['attributes'])) { //fix for 1.3.4
if ($this->attributes_prefix($products_id) == ''){
$the_final_price = $this->attributes_price($products_id);
} else
$the_final_price = ($products_price +
$this->attributes_price($products_id));
}else $the_final_price = ($products_price); //eof actual attribute//hadir
//fix for 1.3.4
///////////////////////
All others
8-In Classes/order.php
above
$this->products[$index] = array('qty' => $products[$i]['quantity'],
Add
//actual attribute price//hadir
if (isset($cart->contents[$products[$i]['id']]['attributes'])) {//fix 1.3.4
if ($cart->attributes_prefix($products[$i]['id']) == ''){
$the_final_price = $cart->attributes_price($products[$i]['id']);
} else
$the_final_price = ($products[$i]['price'] +
$cart->attributes_price($products[$i]['id']));
}else $the_final_price = ($products[$i]['price']); //eof actual
attribute//hadir//fix 1.3.4
///////////////////////////////
9a- for customer group pricing only
under
if ($orders_customers = tep_db_fetch_array($orders_customers_price)) {
add
//actual attribute price//hadir
if (isset($cart->contents[$products[$i]['id']]['attributes'])) {//fix 1.3.4
if ($cart->attributes_prefix($products[$i]['id']) == ''){
$grp_final_price = $cart->attributes_price($products[$i]['id']);
} else
$grp_final_price = ($orders_customers['customers_group_price'] +
$cart->attributes_price($products[$i]['id']));
}else $grp_final_price = ($products[$i]['price']); //eof actual
attribute//hadir//fix 1.3.4
//eof
Ok hopefully this will be the last one.
Thank you all who have emailed me. We found a few bugs and hopefully this is the last one.
Thanks to maxi maximilian for the pointing out the checkout bug.
in classes/order.php
above
$this->products[$index] = array('qty' => $products[$i]['quantity'],
add
//actual attribute price//hadir
if ($cart->attributes_prefix($products[$i]['id']) == ''){
$the_final_price = $cart->attributes_price($products[$i]['id']);
} else
$the_final_price = ($products[$i]['price'] + $cart->attributes_price($products[$i]['id']));
//eof
and change
'final_price' => $products[$i]['price'] + $cart->attributes_price($products[$i]['id']),
to
'final_price' => $the_final_price,
Also fixed bug were I forgot to add a ')' to a line(thanks Mark)
Contains Complete instructions.
I tested this till checkout. Email was correct. Admin Orders was correct and invice was correct.
Someone emailed me saying file was not uploaded correctly.
Here it is again
I forgot to add changes to display the correct price in shopping_cart product rows.
Thanks for the email informing me of this.
This has all the changes that need to be done. NO FILES TO ADD.
changes price to attrinute price if prefix ''
allows 'o'
NOW WORKS WHEN ADDING MORE THAN ONE OF THE SAME PRODUCT TO CART :)
DON"T ADD MY SHOPPING_CART.PHP IN THE FILE TO YOUR DIRECTORY I JUST ADDED IT FOR COMPARISON.
I have several other changes in it that will not work on oscommerce.
All the changes that need to be added are in the txt file
SORRY
I forgot to remove two lines from the older versions I added
YOU DO NOT NEED ANY OTHER FILES OR CHANGES OTHER SHOPPING_CART.php
remove or comment these lines in function attributes_price($products_id) {
in classes/shopping_cart.php
// elseif (($attribute_price['price_prefix'] == '') && ($attribute_price['options_values_price'] != '0')) {
// $attributes_price += tep_adjust_price($attribute_price['options_values_price'],$products_price); }
Can someone please get a full working package up here for this? I've tried myself to action everyones updates and am getting muddled as I'm no developer...
Cheers.
What a great contribution <a href=http://www.dpbuk.co.uk target=_blank>Internet business opportunities</a>
OK This works
worked for me on several sites
Allows attribute price to replace product price when added to cart.
Allows '0' values (might be usefull to some)
For now you can see it at
http://www.dailywholesale.com/product_info.php?products_id=34
works on loaded too
Fixed bug with incorrect final_price when the price_prefix are '-' or '+'.
Fixed bugs when there are more than one attribute for product.
(note: if there are more than one price_prefix of attribute empty ('') for product then it will use just first options_values_price).
Order total now calculate correct totals.
5.01.2005
Artem Yeleyko postmaster@lviv.ws
Fixed bug with special price/product price. If a product had a special price then an incorrect price was calculated on the shopping cart page.
Fixed a Bug in shopping_cart.php which shows up in totals against each item when attributes have price =0 (Showed up as 0 or -ve sometimes)
Works now even with no prefix and 0 price.Works with attributes with no price changes like Color etc.
23/01/2004 - fixed bug in shopping_cart.php which caused subtotal on shopping cart to display incorrectly
on items using actual attribute mod When tax is added to the product price.
Sorry - my update didn't pan out either. We're stuck on this one.
Added the much needed missing categories_lookup.php file found on the authors website in order to make this script work. Also, modified the script to function with v2.2 MS2/CVS important data omitted from the previous release. Good job to the author, we needed something like this.
Changes:
---------------------------
12/10/2003 - found bug in shopping_cart.php that caused attributes with no price and no price prefix to be displayed as negitive numbers in the cart.
fixed the problem with the items with no attributes showing negative prices
This contribution is designed for those of us who would rather use a product attributes actual price rather than use a calculator to figure out the option price.
Example:
--------
Tire A
Price: $84.99
Options: Size 1
Size 2 ($89.99)
Size 3 ($95.99)
Size 4 ($109.99)
Versus
-------
Tire B
Price: $84.99
Options: Size 1
Size 2 ($5.00)
Size 3 ($11.00)
Size 4 ($25.00)
As you can plainly see, it is much easier for a customer to figure out the cost of Tire A Size 4 than it would be for Tire B Size 4.
Installation:
-------------
1. Copy my updated code from:
includes/classes/shopping_cart.php
Includes/functions/general.php
(code is marked by "AAP V1.0")
2. Your are done! Now wasn't that easy?
Using AAP:
----------
It's very simple. When creating a product
attribute, leave the price prefix empty and
insert the price you want to sell the product
for with that attribute. (i.e. Tire A Size 4)
I hope you find this usefull, I know I did.
