2
Answers
Vote up!
0
Vote down!

How do I stop 'Product not available' from being clickable?

Hi,

How do I stop the 'Product not available' button from being clickable? since it doesn't go anywhere.

Or is it possible to make it into a link, ie. to a Contact Us page?

Thank you!

Asked by: joe80
on June 21, 2013

2 Answers

Vote up!
0
Vote down!

Hi,
See http://www.drupalcommerce.org/questions/8363/how-alter-add-cart-button-d... for my solution for this.

I would very much like to add valuable information to this, see my error-message: http://www.drupalcommerce.org/questions/8613/add-cart-errors-when-trying.... May be someone can help with this, because I think this is a needed add on!

Greetings, Martijn

Answer by: Summit
Posted: Jun 22, 2013

Comments

Hi,

Sorry, so are you saying that the code below will make this happen? Where or how do I use this code? –

<?php
/**
* @file
* Adds a link to the contact page when clicking on the add to cart form of a disabled product
*/

/**
* Implements hook_form_FORM_ID_alter(): commerce_cart_add_to_cart_form
*/
function commerce_product_disabled_link_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state, $form_id) {
  if (!empty(
$form['submit']['#attributes']['disabled'])) {
    
$form['contact_link'] = array(
            
'#markup' => l(t('Please contact us'), 'contact'),
       );
   
$form['submit']['#value'] = t('Contact for larger amounts');
    unset(
$form['submit']['#attributes']['disabled']);
    unset(
$form['submit']['#validate']);
   
$form['#validate'] = array();
   
$form['#submit'] = array('commerce_product_disabled_link_commerce_cart_add_to_cart_form_submit');
  }
}

/**
* Add to cart form submit handler.
*/
function commerce_product_disabled_link_commerce_cart_add_to_cart_form_submit($form, &$form_state) {
 
// Set the redirect to the disabled product
  
$form_state['redirect'] = 'contact';
}
?>

Thanks!

- joe80 on June 23, 2013

Hi,
Yes. You have to make a custom module from this.
greetings, Martijn

- Summit on June 28, 2013
Vote up!
-1
Vote down!

Hi, Please google about making drupal custom module. You need to build a .module and a .info fiel and you function need to be named as the custom module name.

greetings, Martijn

Answer by: Summit
Posted: Jul 5, 2013