Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Getting Shopping Cart To Calculate Added Field


cali_cobra

Recommended Posts

Posted

Hello all,

 

I am modifying my shopping cart to allow a user to enter a value and when "update" is clicked, the total amount on an items is entered value*quantity*base price. I have coded the following and it just wont work:

 

shopping_cart.php

 

      $info_box_contents[$cur_row][] = array('params' => 'class="productListing-data"',
                                            'text' => $products_name);
// Added this text box for carat quantity to be entered:
     $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => tep_draw_input_field('carats[]', $products[$i]['carats'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

     $info_box_contents[$cur_row][] = array('align' => 'center',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']));

     $info_box_contents[$cur_row][] = array('align' => 'right',
                                            'params' => 'class="productListing-data" valign="top"',
                                            'text' => '<b>' . $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity'], 

$products[$i]['carats']) . '</b>');
   }

 

 

 

currencies.php

 

    function display_price($products_price, $products_tax, $quantity = 1, $carats = 1) {
     return $this->format(tep_add_tax($products_price, $products_tax) * $quantity * $carats);
   }

 

As you can see, I am trying to add the field carats and pass the carats contents to function display_price. It just isnt working like it should. Can anyone help?

 

:wacko: :wacko: :wacko: :wacko: :wacko: :wacko:

Posted

Just to add, when a value is entered into the carats field and 'update' is clicked, the page reloads and the total amount equals zero no matter what value is entered.

 

Thank you!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...