Results 1 to 10 of 10
  1. #1
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default 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?

  2. #2
    Join Date
    Dec 2010
    Location
    UK
    Posts
    1,771
    Plugin Contributions
    3

    Default 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?

  3. #3
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default Re: which code controls the product price in the cart calculations?

    Quote Originally Posted by picandnix View Post
    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..

  4. #4
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,262
    Plugin Contributions
    3

    Default 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
    19 years a Zencart User

  5. #5
    Join Date
    Jun 2005
    Location
    Cumbria, UK
    Posts
    10,262
    Plugin Contributions
    3

    Default Re: which code controls the product price in the cart calculations?

    Before you "blame" the code, learn how to use your admin panel...
    19 years a Zencart User

  6. #6
    Join Date
    Jul 2005
    Location
    Upstate NY
    Posts
    22,010
    Plugin Contributions
    25

    Default 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.

  7. #7
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default 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?

  8. #8
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default 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.

  9. #9
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default Re: which code controls the product price in the cart calculations?

    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

  10. #10
    Join Date
    Mar 2013
    Posts
    95
    Plugin Contributions
    0

    Default 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

 

 

Similar Threads

  1. what template controls the price display on the front page?
    By ian in forum Templates, Stylesheets, Page Layout
    Replies: 7
    Last Post: 25 Sep 2011, 12:38 PM
  2. Which file controls the category display?
    By earplugs in forum Templates, Stylesheets, Page Layout
    Replies: 2
    Last Post: 13 Jan 2009, 10:17 PM
  3. which page controls the look of the product listings page?
    By what44 in forum Templates, Stylesheets, Page Layout
    Replies: 16
    Last Post: 29 Oct 2007, 10:09 AM
  4. Which one is the class or id that controls the categories listing on top of page
    By qm360 in forum Templates, Stylesheets, Page Layout
    Replies: 4
    Last Post: 9 Jul 2007, 02:35 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR