From 08f24046a4c5c4b6069588d0b5e27a952ef19fd8 Mon Sep 17 00:00:00 2001
From: Peter <aegir@create.simplistechsolutions.com>
Date: Fri, 29 Oct 2010 10:29:02 -0500
Subject: [PATCH] added ability to override submit button

---
 uc_quotes.module |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)

diff --git a/uc_quotes.module b/uc_quotes.module
index 28d123f..9bcbe6a 100644
--- a/uc_quotes.module
+++ b/uc_quotes.module
@@ -18,11 +18,25 @@ function uc_quotes_form_alter(&$form, $form_state, $form_id) {
   if ($form['submit']['#value'] == variable_get('uc_product_add_to_cart_text', t('Add to cart')) && $form['nid']['#value']) {
     if (db_result(db_query("SELECT quote FROM {uc_quotes} WHERE nid = %d", $form['nid']['#value']))) {
       $form['submit']['#value'] = variable_get('uc_add_to_quote_text', 'Add to quote');
+      if (variable_get('uc_quotes_override_check', FALSE)) {
+        $form['#submit'][0] = 'uc_quotes_addtocart_override';
+      }
+
     }
+
   }
   
 }
 
+function uc_quotes_addtocart_override($form) {
+$redirect = variable_get('uc_quotes_overridelink_text', 'contact' );
+if ($redirect == '[node]') {
+  $redirect = 'node/' . $form['nid']['#value'];
+}
+  drupal_goto($redirect);
+}
+
+
 /**
  * Display a formatted list of products.
  *
@@ -385,6 +399,19 @@ function uc_quotes_feature_settings() {
     '#description' => t('Adjust the text of the submit button for <em>Add to Quote</em> forms in various places on the site.'),
     '#default_value' => variable_get('uc_add_to_quote_cart_text', t('(Price Inquiry)')),
   );
+  $form['uc_quotes_override_check'] = array(
+    '#type' => 'checkbox',
+    '#title' => t('Override the submit button to redirect.'),
+    '#description' => t('Select if you want to redirect the submit button the url below.'),
+    '#default_value' => variable_get('uc_quotes_override_check', FALSE),
+  );
+  $form['uc_quotes_overridelink_text'] = array(
+    '#type' => 'textfield',
+    '#title' => t("Override Redirect url"),
+    '#description' => t('Add the url you want to redirect to.  Add <code>[node]</code> to redirect to the product node.  This wont work unless you check the override checkbox above.'),
+    '#default_value' => variable_get('uc_quotes_overridelink_text', t('contact')),
+  );
+
   return $form;
 }
 
@@ -393,4 +420,4 @@ function uc_quotes_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
     $node->content['display_price']['#value'] = '<div class="quotes-inquiry">'. t('Inquire for pricing') .'</div>';
     $node->content['sell_price']['#value'] = '<div class="quotes-inquiry">'. t('Inquire for pricing') .'</div>';
   } 
-}
\ No newline at end of file
+}
-- 
1.5.4.3

