Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Why will this form not submit to the cart?


Guest

Recommended Posts

So I have this form (see below) and I am trying to get it to submit to the cart but it will not for some reason. It is a contribution which I am modifying called 'Impulse Item'. I have already been in touch with the programmer who submitted it but they diddnt know what to do (or have the time)

 

Maybe I just need another set of eyes to look this over.. THANK YOU to anyone who can help me with this issue.. I have come to the conclusion that it is just the positioning of the form tags or the 'add to cart' button..

 

Here is the code (the form tags and add to cart button are in red)

 

 

 

 

 

 

 

<!-- Impulse Item by jfj -->

 

<tr>

 

<td> <table border="0" width="100%" cellspacing="0" cellpadding="2">

 

<tr>

 

<td class="main"><?php echo tep_draw_form('cart_quantity', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_product')); ?><input type="hidden" name="products_id" value="' . $specials2['products_id'] . '"><?php

/*

$Id: Impulse Item, v0.1 2005/10/22

(contrib based on osc's specials.php)

Created by Fredrik Johansson (aka jfj or redrum)

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

Copyright ? 2003 osCommerce

Released under the GNU General Public License

*/

 

$specials2_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS_CHECKOUT . " s where s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC";

 

$specials2_split = new splitPageResults($specials2_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);

 

if (($specials2_split->number_of_rows > 3) && ((PREV_NEXT_BAR_LOCATION == '3') || (PREV_NEXT_BAR_LOCATION == '3'))) {

?>

<br>

<?php

}

?>

<style type="text/css">

<!--

.style1 {

font-family: Arial, Helvetica, sans-serif;

font-size: 11px;

}

-->

</style>

 

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

 

 

 

 

<?php

$row = 0;

$specials2_query = tep_db_query($specials2_split->sql_query);

while ($specials2 = tep_db_fetch_array($specials2_query)) {

$row++;

 

 

echo ' <script language="javascript"><!--

function popupWindow(url) {

window.open(url,\'popupWindow\',\& #39;toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res

 

izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,l

 

eft=150\')

}

//--></script>

 

<td align="center" width="33%" class="smallText">

 

<script language="javascript"><!--

//--></script>

<noscript>

<a href="' . tep_href_link(DIR_WS_IMAGES . $specials2['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $specials2['products_image'], $specials2['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5" class="bild"') . '<br><img src="includes/languages/svenska/images/buttons/click_to_enlarge.gif" alt="klicka f?r st?rre bild" width="90" height="18" border="0"></a>

</noscript>

<br>

' . $specials2['products_name'] . '

<br>

 

<br>

<input type="text" name="quantity" value="0" maxlength="5" size="5">

</td>' . "\n";

 

if ((($row / 3) == floor($row / 3))) {

?>

</tr>

<tr>

 

</tr>

<tr>

<?php

}

}

?>

</tr>

</table></td>

</tr>

<?php

if (($specials2_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {

?>

 

<?php

}

?>

</td>

 

</tr>

 

</table><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?><form><td></tr>

 

<!-- Impulse Item by jfj -->

Link to comment
Share on other sites

<td class="main"><?php echo tep_draw_form('cart_quantity', tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_product')); ?><input type="hidden" name="products_id" value="' . $specials2['products_id'] . '"><?php
Interesting: PHP should have knowledge about the products_id you are going to query later? I suppose this hidden value can and should be after that. Also you seem to have several products, how come you only submit one products_id?
</table><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?><form><td></tr>
Should be a </form> tag instead of <form>.
Link to comment
Share on other sites

Thanks for the help so far, I am getting there I believe..

 

I changed the <form> to </form> and moved a couple things around, now it is only adding the last product to the cart.

 

any ideas?

 

 

 

 

 

<!-- Impulse Item by jfj -->

 

<tr>

 

<td> <table border="0" width="100%" cellspacing="0" cellpadding="2">

 

<tr>

 

<td class="main"><?php

/*

$Id: Impulse Item, v0.1 2005/10/22

(contrib based on osc's specials.php)

Created by Fredrik Johansson (aka jfj or redrum)

osCommerce, Open Source E-Commerce Solutions

http://www.oscommerce.com

Copyright ? 2003 osCommerce

Released under the GNU General Public License

*/

 

$specials2_query_raw = "select p.products_id, pd.products_name, p.products_price, p.products_tax_class_id, p.products_image, s.specials_new_products_price from " . TABLE_PRODUCTS . " p, " . TABLE_PRODUCTS_DESCRIPTION . " pd, " . TABLE_SPECIALS_CHECKOUT . " s where s.products_id = p.products_id and p.products_id = pd.products_id and pd.language_id = '" . (int)$languages_id . "' and s.status = '1' order by s.specials_date_added DESC";

 

$specials2_split = new splitPageResults($specials2_query_raw, MAX_DISPLAY_SPECIAL_PRODUCTS);

 

if (($specials2_split->number_of_rows > 3) && ((PREV_NEXT_BAR_LOCATION == '3') || (PREV_NEXT_BAR_LOCATION == '3'))) {

?>

<br>

<?php

}

?>

<style type="text/css">

<!--

.style1 {

font-family: Arial, Helvetica, sans-serif;

font-size: 11px;

}

-->

</style>

 

<tr>

<td><table border="0" width="100%" cellspacing="0" cellpadding="2">

<tr>

 

 

 

 

<?php

$row = 0;

$specials2_query = tep_db_query($specials2_split->sql_query);

while ($specials2 = tep_db_fetch_array($specials2_query)) {

$row++;

 

 

echo ' <script language="javascript"><!--

function popupWindow(url) {

window.open(url,\'popupWindow\',\& #39;toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=no,res

 

 

izable=yes,copyhistory=no,width=100,height=100,screenX=150,screenY=150,top=150,l

 

 

eft=150\')

}

//--></script>

<form name="cart_quantity" method="post" action="' . tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action')) . 'action=add_product', 'NONSSL'). '">

<td align="center" width="33%" class="smallText">

 

<script language="javascript"><!--

//--></script>

<noscript>

<a href="' . tep_href_link(DIR_WS_IMAGES . $specials2['products_image']) . '" target="_blank">' . tep_image(DIR_WS_IMAGES . $specials2['products_image'], $specials2['products_name'], SMALL_IMAGE_WIDTH, SMALL_IMAGE_HEIGHT, 'hspace="5" vspace="5" class="bild"') . '<br><img src="includes/languages/svenska/images/buttons/click_to_enlarge.gif" alt="klicka f?r st?rre bild" width="90" height="18" border="0"></a>

</noscript>

<br>

' . $specials2['products_name'] . '

<br>

 

<br>

<input type="hidden" name="products_id" value="' . $specials2['products_id'] . '"><input type="text" name="quantity" value="0" maxlength="5" size="5">

</td>' . "\n";

 

if ((($row / 3) == floor($row / 3))) {

?>

</tr>

<tr>

 

</tr>

<tr>

<?php

}

}

?>

</tr>

</table></td>

</tr>

<?php

if (($specials2_split->number_of_rows > 0) && ((PREV_NEXT_BAR_LOCATION == '2') || (PREV_NEXT_BAR_LOCATION == '3'))) {

?>

 

<?php

}

?>

</td>

 

</tr>

 

</table><?php echo tep_image_submit('button_in_cart.gif', IMAGE_BUTTON_IN_CART); ?></form><td></tr>

 

<!-- Impulse Item by jfj -->

Link to comment
Share on other sites

I have spent 20 hours trying to figure this one out, Ill pay someone to solve this for me.. PM me..

 

The form will not submit anything to the cart besides the last product and its quantity.

 

I have tried moving the form tags around, Ive tried every possible combination.. Its driving me mad.

 

Thanks for any help, free or paid!

Link to comment
Share on other sites

Is the store you're working on modified with the Register Globals patch?

Local: Mac OS X 10.5.8 - Apache 2.2/php 5.3.0/MySQL 5.4.10 • Web Servers: Linux

Tools: BBEdit, Coda, Versions (Subversion), Sequel Pro (db management)

Link to comment
Share on other sites

Thank you both for responding..

 

 

Is the store you're working on modified with the Register Globals patch?

 

No, not that I know of.

 

I would try changing this to value="1"

 

<input type="text" name="quantity" value="0" maxlength="5" size="5">

 

This made the text boxes change from displaying a 0 to displaying a 1.. Still, only the last item was added to the cart.

 

 

 

 

I think it has something to do with the form positioning.. All I really need is 12 boxes where they can enter a quantity and add them to the cart on the checkout_shipping.php page.

 

Do you think I could I do this in HTML and pass along a product id to the cart?

 

It would be ideal if I could just include a single category and have it display above the shipping info area of the page too.. Actually, it would be ideal if I could get this to work.. : )

 

 

 

Thanks again

Link to comment
Share on other sites

I just looked at the impulse contribution, it use the buy_now action which uses a submit. If you are only going to have one submit button then you need to build an array of all the products that have been selected to pass to the cart when you press submit. You can look at the Products Multi Contribution for how to do this. Add Multi Products Revived.

while (!succeed) {try()};

 

GMT -6:00

Link to comment
Share on other sites

Archived

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

×
×
  • Create New...