Solved

Oscommerce: How do I replace product delete checkbox with product delete image?

Posted on 2007-12-04
3
332 Views
Last Modified: 2013-12-12
I'm working in OScommerce on shopping_cart.php where originally the user had to check a box and then hit the update button to remove the item from the shopping cart.  I've managed to get the checkbox to remove the item automatically, but what I'd like to do is replace the checkbox with an image. (that works in the same fashion)

The code below (starting with (tep_draw_checkbox_field) does what I want it to do, but when I try something similar with 'tep_image_submit' or 'tep_image_button' it doesn't work.

Thank you for any help/advice you can give me.
$info_box_contents[$cur_row][] = array('align' => 'center',

                                             'params' => 'class="productListing-data" valign="top"',

                                             'text' => tep_draw_checkbox_field('cart_delete[]', $products[$i]['id'],'', 'onclick="document.cart_quantity.submit();"',false));//auto update cart

Open in new window

0
Comment
Question by:figure8labs
  • 3
3 Comments
 
LVL 20

Expert Comment

by:steelseth12
ID: 20402067
this is how i have it setup ....



$info_box_contents[$cur_row][] = array('align' => 'center',

                                             'params' => 'class="productListing-data" valign="top"',

                                             'text' => "<a href=''  onClick=\"winconfirm('".tep_href_link("shopping_cart.php")."?action=custom_delete&products_id=".$products[$i]['id']."','Are you sure you want to delete this Item?'); return false;\">".tep_image('images/cancel.gif'));

Open in new window

0
 
LVL 20

Expert Comment

by:steelseth12
ID: 20402068
the confirm javascript
function winconfirm(varURL,varMSG){
 

	question = confirm(varMSG)
 

	if (question != "0"){

		

		if(varURL =="") {

		

			document.submit();

			

		}else {

		

			window.location=varURL

			

		}

	}

}

</script>

Open in new window

0
 
LVL 20

Accepted Solution

by:
steelseth12 earned 500 total points
ID: 20402071
and in application_top.php i added...

case 'custom_delete' :
            
            
            $cart->remove($_REQUEST['products_id']);
            
            break;

in
switch ($_REQUEST['action']) {

	

		case 'custom_delete' :

		

		

		$cart->remove($_REQUEST['products_id']);

		

		break;

	

      // customer wants to update the product quantity in their shopping cart

      case 'update_product' : for ($i=0, $n=sizeof($HTTP_POST_VARS['products_id']); $i<$n; $i++) {

                                if (in_array($HTTP_POST_VARS['products_id'][$i], (is_array($HTTP_POST_VARS['cart_delete']) ? $HTTP_POST_VARS['cart_delete'] : array()))) {

                                  $cart->remove($HTTP_POST_VARS['products_id'][$i]);

                                } else {

                                  if (PHP_VERSION < 4) {

                                    // if PHP3, make correction for lack of multidimensional array.

                                    reset($HTTP_POST_VARS);

                                    while (list($key, $value) = each($HTTP_POST_VARS)) {

                                      if (is_array($value)) {

                                        while (list($key2, $value2) = each($value)) {

                                          if (ereg ("(.*)\]\[(.*)", $key2, $var)) {

                                            $id2[$var[1]][$var[2]] = $value2;

                                          }

                                        }

                                      }

                                    }

                                    $attributes = ($id2[$HTTP_POST_VARS['products_id'][$i]]) ? $id2[$HTTP_POST_VARS['products_id'][$i]] : '';

                                  } else {

                                    $attributes = ($HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]]) ? $HTTP_POST_VARS['id'][$HTTP_POST_VARS['products_id'][$i]] : '';

                                  }

                                  $cart->add_cart($HTTP_POST_VARS['products_id'][$i], $HTTP_POST_VARS['cart_quantity'][$i], $attributes, false);

                                }

                              }

                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

                              break;

      // customer adds a product from the products page

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

                                $cart->add_cart($HTTP_POST_VARS['products_id'], $cart->get_quantity(tep_get_uprid($HTTP_POST_VARS['products_id'], $HTTP_POST_VARS['id']))+1, $HTTP_POST_VARS['id']);

                              }

                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

                              break;

      // performed by the 'buy now' button in product listings and review page

      case 'buy_now' :        if (isset($HTTP_GET_VARS['products_id'])) {

                                if (tep_has_product_attributes($HTTP_GET_VARS['products_id'])) {

                                  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['products_id']));

                                } else {

                                  $cart->add_cart($HTTP_GET_VARS['products_id'], $cart->get_quantity($HTTP_GET_VARS['products_id'])+1);

                                }

                              }

                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

                              break;

      case 'notify' :         if (tep_session_is_registered('customer_id')) {

                                if (isset($HTTP_GET_VARS['products_id'])) {

                                  $notify = $HTTP_GET_VARS['products_id'];

                                } elseif (isset($HTTP_GET_VARS['notify'])) {

                                  $notify = $HTTP_GET_VARS['notify'];

                                } elseif (isset($HTTP_POST_VARS['notify'])) {

                                  $notify = $HTTP_POST_VARS['notify'];

                                } else {

                                  tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));

                                }

                                if (!is_array($notify)) $notify = array($notify);

                                for ($i=0, $n=sizeof($notify); $i<$n; $i++) {

                                  $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $notify[$i] . "' and customers_id = '" . $customer_id . "'");

                                  $check = tep_db_fetch_array($check_query);

                                  if ($check['count'] < 1) {

                                    tep_db_query("insert into " . TABLE_PRODUCTS_NOTIFICATIONS . " (products_id, customers_id, date_added) values ('" . $notify[$i] . "', '" . $customer_id . "', now())");

                                  }

                                }

                                tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action', 'notify'))));

                              } else {

                                $navigation->set_snapshot();

                                tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

                              }

                              break;

      case 'notify_remove' :  if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['products_id'])) {

                                $check_query = tep_db_query("select count(*) as count from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");

                                $check = tep_db_fetch_array($check_query);

                                if ($check['count'] > 0) {

                                  tep_db_query("delete from " . TABLE_PRODUCTS_NOTIFICATIONS . " where products_id = '" . $HTTP_GET_VARS['products_id'] . "' and customers_id = '" . $customer_id . "'");

                                }

                                tep_redirect(tep_href_link(basename($PHP_SELF), tep_get_all_get_params(array('action'))));

                              } else {

                                $navigation->set_snapshot();

                                tep_redirect(tep_href_link(FILENAME_LOGIN, '', 'SSL'));

                              }

                              break;

      case 'cust_order' :     if (tep_session_is_registered('customer_id') && isset($HTTP_GET_VARS['pid'])) {

                                if (tep_has_product_attributes($HTTP_GET_VARS['pid'])) {

                                  tep_redirect(tep_href_link(FILENAME_PRODUCT_INFO, 'products_id=' . $HTTP_GET_VARS['pid']));

                                } else {

                                  $cart->add_cart($HTTP_GET_VARS['pid'], $cart->get_quantity($HTTP_GET_VARS['pid'])+1);

                                }

                              }

                              tep_redirect(tep_href_link($goto, tep_get_all_get_params($parameters)));

                              break;

    }

  }

Open in new window

0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Although it can be difficult to imagine, someday your child will have a career of his or her own. He or she will likely start a family, buy a home and start having their own children. So, while being a kid is still extremely important, it’s also …
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now