2
Answers
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!
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!
Hi,
Yes. You have to make a custom module from this.
greetings, Martijn
Hi,
How do I do that?