Jump to content

Archived

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

nastea

Two Items Added When Added to Cart

Recommended Posts

When adding products to the cart, I'm getting two products added. I'm sure it is an easy problem but not sure where to even start. You find a product, click add after clicking size etc. Then when it takes you to the cart you have two added.

Any pointers?

Share this post


Link to post
Share on other sites

What version of osC are you using? What add-ons did you install or did you install any add-on that could affect the add to cart button or the shopping_cart.php file?

Did it ever work before?

Share this post


Link to post
Share on other sites

It did work before, I have quite a few addons, it started happening after I loaded QTPro but the admin/author of that addon hasn't replied. So I figured I'd at least get someone to tell me where I can look. It worked fine before the QTpro load and I'm using 2.3.4. 

Share this post


Link to post
Share on other sites

Here is the shopping_cart.php

<?php
/*
  $Id$

  osCommerce, Open Source E-Commerce Solutions
  http://www.oscommerce.com

  Copyright (c) 2010 osCommerce

  Released under the GNU General Public License
*/

  require("includes/application_top.php");

  if ($cart->count_contents() > 0) {
    include(DIR_WS_CLASSES . 'payment.php');
    $payment_modules = new payment;
  }

  require(DIR_WS_LANGUAGES . $language . '/' . FILENAME_SHOPPING_CART);

  $breadcrumb->add(NAVBAR_TITLE, tep_href_link(FILENAME_SHOPPING_CART));

  require(DIR_WS_INCLUDES . 'template_top.php');
?>

<h1><?php echo HEADING_TITLE; ?></h1>

<?php
  if ($cart->count_contents() > 0) {
?>

<?php echo tep_draw_form('cart_quantity', tep_href_link(FILENAME_SHOPPING_CART, 'action=update_product')); ?>
<div id="mj-shoppingcart">
<div class="contentContainer">
  <div class="contentText">

<?php
    $any_out_of_stock = 0;
    $products = $cart->get_products();
    for ($i=0, $n=sizeof($products); $i<$n; $i++) {
// Push all attributes information in an array
      if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
        while (list($option, $value) = each($products[$i]['attributes'])) {
          echo tep_draw_hidden_field('id[' . $products[$i]['id'] . '][' . $option . ']', $value);
 $attributes = tep_db_query("select popt.products_options_name, popt.products_options_track_stock, poval.products_options_values_name, pa.options_values_price, pa.price_prefix


from " . TABLE_PRODUCTS_OPTIONS . " popt, " . TABLE_PRODUCTS_OPTIONS_VALUES . " poval, " . TABLE_PRODUCTS_ATTRIBUTES . " pa
                                      where pa.products_id = '" . (int)$products[$i]['id'] . "'
                                       and pa.options_id = '" . (int)$option . "'
                                       and pa.options_id = popt.products_options_id
                                       and pa.options_values_id = '" . (int)$value . "'
                                       and pa.options_values_id = poval.products_options_values_id
                                       and popt.language_id = '" . (int)$languages_id . "'
                                       and poval.language_id = '" . (int)$languages_id . "'");
          $attributes_values = tep_db_fetch_array($attributes);

          $products[$i][$option]['products_options_name'] = $attributes_values['products_options_name'];
          $products[$i][$option]['options_values_id'] = $value;
          $products[$i][$option]['products_options_values_name'] = $attributes_values['products_options_values_name'];
          $products[$i][$option]['options_values_price'] = $attributes_values['options_values_price'];
          $products[$i][$option]['price_prefix'] = $attributes_values['price_prefix'];
                  $products[$i][$option]['track_stock'] = $attributes_values['products_options_track_stock'];

        }
      }
    }
?>

    <table border="0" width="100%" cellspacing="0" cellpadding="10">
        <tbody>
                <tr class="tableHeading">
                <th><?php echo PRODUCT_TITLE_CART; ?></th>
                <th><?php echo PRODUCT_QTY_CART; ?></th>
                <th><?php echo PRODUCT_UPDATE_CART; ?></th>
                                <th><?php echo PRODUCT_REMOVE_CART; ?></th>
                <th><?php echo ENTRY_TOTAL_CART; ?></th>
            </tr>
<?php

    for ($i=0, $n=sizeof($products); $i<$n; $i++) { ?>
        <tr class="tablecontent">
                <td align="center" class="product_info_image">
                <?php
                                if (STOCK_CHECK == 'true') {
//++++ QT Pro: Begin Changed code
        if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
          $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity'], $products[$i]['attributes']);
 }else{
          $stock_check = tep_check_stock($products[$i]['id'], $products[$i]['quantity']);
        }
//++++ QT Pro: End Changed Code

if (tep_not_null($stock_check)) {
                                                        $any_out_of_stock = 1;
                                                        $products_name_q = $stock_check;
                                                }
                                }
                                ?>
                                <?php
                        if (isset($products[$i]['attributes']) && is_array($products[$i]['attributes'])) {
                                                reset($products[$i]['attributes']);
                                        while (list($option, $value) = each($products[$i]['attributes'])) {
                                                $products[$i]['name'] .= '<br /><small><i> - ' . $products[$i][$option]['products_options_name'] . ' ' .
                                                        $products[$i][$option]['products_options_values_name'] . '</i></small>';
                                        }
                        } ?>
                <a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']);?>"> <?php echo tep_image(DIR_WS_IMAGES . $products[$i]['image'],
                                                $products[$i]['name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT); ?>
                </a><br/>
                <a href="<?php echo tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $products[$i]['id']);?>">
                                <strong><?php echo $products[$i]['name'] . $products_name_q; ?></strong>
                </a>
            </td>
                <td align="center">
                                <?php echo tep_draw_input_field('cart_quantity[]', $products[$i]['quantity'], 'size="4"') . tep_draw_hidden_field('products_id[]', $products[$i]['id']); ?>
            </td>
                <td align="center">
                                <?php echo tep_draw_button(IMAGE_BUTTON_UPDATE, 'refresh'); ?>
            </td>
                <td align="center">
                <span class="link_button">
                        <a href="<?php echo tep_href_link(FILENAME_SHOPPING_CART, 'products_id=' . $products[$i]['id'] . '&action=remove_product'); ?>"> <?php echo /*TEXT_REMOVE*/
                                        "Remove"; ?> </a>
                </span>
            </td>
                <td align="center" valign="middle"><strong>
                                <?php echo $currencies->display_price($products[$i]['final_price'], tep_get_tax_rate($products[$i]['tax_class_id']), $products[$i]['quantity']); ?></strong>
            </td>
 </tr>
                <?php  }
                ?>
        </tbody>
    </table>
    <div id="cartSubTotal"><?php echo SUB_TITLE_SUB_TOTAL; ?> <?php echo $currencies->format($cart->show_total()); ?></div>
        <?php
        if ($any_out_of_stock == 1) {
        if (STOCK_ALLOW_CHECKOUT == 'true') {
        ?>
    <p class="stockWarning" align="center"><?php echo OUT_OF_STOCK_CAN_CHECKOUT; ?></p>
        <?php
      } else {
        ?>
    <p class="stockWarning" align="center"><?php echo OUT_OF_STOCK_CANT_CHECKOUT; ?></p>
        <?php
         }
        }
        ?>
  </div>
  <div class="buttonSet">
    <span class="link_button"><?php echo tep_draw_button(IMAGE_BUTTON_CHECKOUT, 'triangle-1-e', tep_href_link(FILENAME_CHECKOUT_SHIPPING, '', 'SSL'), 'primary'); ?></span>
        <?php
    $initialize_checkout_methods = $payment_modules->checkout_initialization_method();
    if (!empty($initialize_checkout_methods)) {
      reset($initialize_checkout_methods);
      while (list(, $value) = each($initialize_checkout_methods)) { ?>
         <span class="other_options"> <?php echo $value; ?></span>
     <span class="alternate_text"><?php echo TEXT_ALTERNATIVE_CHECKOUT_METHODS; ?> </span>
     <?php  }
    }
?>



  </div>

</div>
</div>
</form>
<?php
  } else {
?>
<div id="mj-shoppingcart">
<div class="contentContainer">
  <div class="content_box">
    <?php echo TEXT_CART_EMPTY; ?>
        <br/> <br/>
    <span class="link_button"><?php echo tep_draw_button(IMAGE_BUTTON_CONTINUE, 'triangle-1-e', tep_href_link(FILENAME_DEFAULT)); ?></span>
  </div>
</div>
</div>
<?php
  }

  require(DIR_WS_INCLUDES . 'template_bottom.php');
  require(DIR_WS_INCLUDES . 'application_bottom.php');
?>


Share this post


Link to post
Share on other sites

The file shopping_cart.php is not relevant

 

Post the lines from your file includes/application_top.php, only the "case: add_product"

 

that start with

      case 'add_product' :    if (isset($HTTP_POST_VARS['products_id']) && is_numeric($HTTP_POST_VARS['products_id'])) {

and end with

                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));
                              break;
      // customer removes a product from their shopping cart

Share this post


Link to post
Share on other sites

×