Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8103959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:41:57+00:00 2026-06-05T23:41:57+00:00

I have the following class in a php file: function calcTotal(){ var productID =

  • 0

I have the following class in a php file:

function calcTotal(){
        var productID = <?php echo $product_info['products_id'];?>;
    var sizeID = 0; 

    $(".mine_sizes").each(function() {
          if ($(this).is(':checked'))  sizeID = $(this).val();                         
     });
    //alert(sizeID);
    var colorID = 0;

    $(".mine_color").each(function() {
          if ($(this).is(':checked'))  colorID = $(this).val();                        
     });

     $.ajax({
              type: "POST",
              url: 'get_product_price.php',
              data: "product_id="+ productID +"&color_id="+ colorID +"&size_id="+ sizeID,
              success: function( response ) {       
                    $("#price_container").html(response);
                    ;

              } 

     });

}

and the php file get_product_price.php:

if($_POST){

     $product_info_query = tep_db_query("select products_price, products_tax_class_id from " . TABLE_PRODUCTS . "  where products_id = '" . (int)$_POST['product_id']."'");
     $pricePrice = tep_db_fetch_array($product_info_query);
     $productPrice = $pricePrice['products_price'];

    $sizesPrices = tep_db_query("select options_values_price from products_attributes   where products_id='".$_POST['product_id']."' and options_values_id='".$_POST['size_id']."'");
 //  echo "select options_values_price from products_attributes   where products_id='".$_POST['product_id']."' and options_values_id='".$_POST['size_id']."'";
  // exit;
    if(mysql_num_rows($sizesPrices)>0){
        $priceRow = tep_db_fetch_array($sizesPrices);
        $productPrice = $productPrice + $priceRow['options_values_price'];
    }

    $sizesPrices2 = tep_db_query("select price from product_attributes_color_relation   where product_id='".$_POST['product_id']."' and color_id='".$_POST['color_id']."' and color_size_option_id='".$_POST['size_id']."'");

    if(mysql_num_rows($sizesPrices2)>0){
        $priceRow2 = tep_db_fetch_array($sizesPrices2);
        $productPrice = $productPrice + $priceRow2['price'];
    }
    //echo $productPrice; exit;
    echo $currencies->display_price($productPrice, tep_get_tax_rate($product_info['products_tax_class_id']));
    //echo $productPrice;
}

The function is called on a radio button click and is currently working but I am trying to understand how it works for myself (and to possibly recreate a similar function)

What I am not really understanding is the data parameter from the ajax api. How is that data parameter used?

another question I have is the success parameter. Is the “response” parameter a standard or can in be called anything?

Thanks for any help explaining this to me. I don’t think any other information is necessary, there is a div with a class id #price_container which is where the price is echo’d.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T23:41:58+00:00Added an answer on June 5, 2026 at 11:41 pm

    The data parameter passes the information the same way an HTML form will. At least that’s the easiest way to think of it. So that “data” will come through as $_POST or $_GET arrays. I always setup my data as JSON format:

    data: { "product_id": productID,"color_id": colorID, "size_id": sizeID },
    

    With your type set as “POST” that would come through as:

    $_POST['product_id']
    $_POST['color_id']
    $_POST['size_id']
    

    You can specify any variable name for the response – but ‘response’ is nice and easy to remember and work with. 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following controller file: <?php class Test extends CI_Controller { function __construct()
I have a application/controller/login.php file containing the following class Login extends Controller { function
I have the following code in controllers/list.php: <?php class List extends Controller { function
I have the following question: This is my main file index.php . <?php class
In PHP, I have following Singleton Database Class: class Database { private static $instance;
I have the following code: $(document).ready(function() { $.getJSON('../includes/_quiz.php?class_id=163&course_id=183',function(data){ $.each(data,function(k,v){ questions[k] = v.question; answers[k*4] =
this is my first question I Have following class class ProDetection { public function
I have create the following class : Main class file class NativeTabs { private
I have a php file, say include.php which has the following contents: <?php $myVar
I have defined a searchform in the Page.php file function AdvancedSearchForm() { $searchText =

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.