which code controls the product price in the cart calculations?
hey guys, want to ask which file or codes controls the product price in the cart? i dont know why but my quoted price when i add to the cart and the actual price is different as seen in the pic.
the quoted price i got is 2000, but the price when i added into the cart becomes 1499
quoted price: http://img831.imageshack.us/img831/3164/capture1qs.png
price in cart: http://img401.imageshack.us/img401/28/captureke.png
where can i fnid the file that affects this?
Re: which code controls the product price in the cart calculations?
it's from the database.
do you have a discount set up?
Are you logged in as a customer, is it any different when not logged in?
Do you have any mods installed?
Re: which code controls the product price in the cart calculations?
Quote:
Originally Posted by
picandnix
it's from the database.
do you have a discount set up?
Are you logged in as a customer, is it any different when not logged in?
Do you have any mods installed?
im logged in, no discount set up, but i have a price per word attribute that i modified to calculate length*width, the problem im facing is, when i edit the function zen_get_word_count_price in function_prices.php to this:
Code:
function zen_get_word_count_price($string, $free=0, $price) {
$actual_price = zen_get_products_actual_price($products_id);
$squareFoot = explode("x",$string);
if($squareFoot[0]<0||$squareFoot[1]<0) {
return 0;
} else if($squareFoot[0]>50||$squareFoot[1]>10){
return 0;
} else if(count($squareFoot) == 1){
return 0;
}else{
$pricePerSqFoot = ($squareFoot[0] * $squareFoot[1] * $price -$actual_price);
return $pricePerSqFoot;
}
}
it doesnt calculate correctly, but only when i use this:
Code:
function zen_get_word_count_price($string, $free=0, $price) {
$actual_price = zen_get_products_actual_price($products_id);
$squareFoot = explode("x",$string);
if($squareFoot[0]<0||$squareFoot[1]<0) {
return 0;
} else if($squareFoot[0]>50||$squareFoot[1]>10){
return 0;
} else if(count($squareFoot) == 1){
return 0;
}else{
$pricePerSqFoot = ($squareFoot[0] * $squareFoot[1] * $price -$price);
return $pricePerSqFoot;
}
}
it calculates correctly, but not what i wanted.. in my mind i think i know why, yet at the same time i have no idea why.. the function should've returned the correct calculation, then add it to the $attributes_price variable in the shopping_cart.php class, yet somehow somewhere in the middle, the $actual_price got lost somewhere..
Re: which code controls the product price in the cart calculations?
Check your CURRENCY setting in your admin panel. make sure you have a DEFAULT currency selected and its value is 1.00000000000 . Then UPDATE CURRENCIES to get latest exchange rates
Re: which code controls the product price in the cart calculations?
Before you "blame" the code, learn how to use your admin panel... :smile:
Re: which code controls the product price in the cart calculations?
Why do you think you need to change the way the price is returned? The original function gives the attribute price based on its calculation of the number of words x price per word; you should be able to return the correct square foot price by calculating the number of square feet x the price per square foot. The product's base price doesn't need to enter into it, if you have the product set up correctly.
We need to know exactly how you have the product configured *and* how you want it to behave to advise on why it isn't working, though I suspect you have a nonzero base price and are trying to replace that with the calculated square foot price.
PHP Code:
// calculate words price
function zen_get_word_count_price($string, $free=0, $price) {
$word_count = zen_get_word_count($string, $free);
if ($word_count >= 1) {
return ($word_count * $price);
} else {
return 0;
}
}
PHP Code:
function zen_get_word_count_price($string, $free=0, $price) {
$actual_price = zen_get_products_actual_price($products_id);
$squareFoot = explode("x",$string);
if($squareFoot[0]<0||$squareFoot[1]<0) {
return 0;
} else if($squareFoot[0]>50||$squareFoot[1]>10){
return 0;
} else if(count($squareFoot) == 1){
return 0;
}else{
$pricePerSqFoot = ($squareFoot[0] * $squareFoot[1] * $price -$actual_price);
return $pricePerSqFoot;
}
}
Try this, with the product price set to 0, "priced by attributes", and the attribute price set to the square foot base:
PHP Code:
function zen_get_word_count_price($string, $free=0, $price) {
$squareFoot = explode("x",$string);
if($squareFoot[0]<0||$squareFoot[1]<0) {
return 0;
} else if($squareFoot[0]>50||$squareFoot[1]>10){
return 0;
} else if(count($squareFoot) == 1){
return 0;
}else{
$sqFootPrice = ($squareFoot[0] * $squareFoot[1] * $price);
return $sqFootPrice;
}
}
Seeing it in action may be helpful.
Re: which code controls the product price in the cart calculations?
thanks for the codes gjh42, i'll look into it, as for what i did, i changed the code for the price per word calculation in the shopping_cart class and the function_prices.php files.. here's what i did:
in function_prices.php line 1166
Code:
////
// calculate words price
function zen_get_word_count_price($products_id, $string, $free=0, $price) {
$actual_price = zen_get_products_actual_price($products_id);
$squareFoot = explode("x",$string);
if($squareFoot[0]<0||$squareFoot[1]<0) {
return 0;
} else if($squareFoot[0]>50||$squareFoot[1]>10){
return 0;
} else if(count($squareFoot) == 1){
return 0;
}else{
$pricePerSqFoot = ($squareFoot[0] * $squareFoot[1] * $price -$actual_price);
return $pricePerSqFoot;
}
}
here i add in the products_id variable to the function, if i add this it wont calculate correctly when added to the cart anymore, the calculation in the product page still works though. also, if i remove the $products_id it works, im guessing there's a function used somewhere that i have to add the variable to, i used the dev toolkit to find them all and changed them but it stil didnt work..
in the shopping_cart.php class line 520 i add in:
Code:
$text_words = zen_get_word_count_price($product->fields['products_id'], $this->contents[$products_id]['attributes_values'][$attribute_price->fields['options_id']], $attribute_price->fields['attributes_price_words_free'], $attribute_price->fields['attributes_price_words']);
what can i do so that the function calculates correctly with the $oroducts_id?
Re: which code controls the product price in the cart calculations?
also, the reason why i wanted to make the function that way is because the way my product is calculated is base on the base price X width x height, certain products are listed with their base price and those i can do by minusing the base price using -$price. but some products are listed with a set price and not their base price, so for those i have to minus their actual price to get the correct calculation.
Re: which code controls the product price in the cart calculations?
Quote:
working, though I suspect you have a nonzero base price and are trying to replace that with the calculated square foot price.
yes that is what im trying to do, i can do it if i use the attributes as the based price as you said, but certain products requires me to use a set price instead of the base price in the listing
Re: which code controls the product price in the cart calculations?
ok i managed to solve the problem by butchering the codes even further (so sorry)
anyway, instead of using one variable price per word for both the products with base price listing and products with a set price but also use base price calculation, i decided to just use a different variable, in this case i butchered the price factor and offset codes and made it to calculate what i want, and i added the text that shows when you have price per word to correspond to price factor as well, everything works fine now.. thanks for the help guys