Warning message

Newsletter category Drupal Developer newsletter format has not been set to HTML. There will be no statistics recorded for this newsletter.

Drupal: Commerce buy now

This CodeLet will redirect the user to checkout page when user clicks on 'Buy now' button on the product

Use the code and create a custom module

Make sure you keep the weight of the module high in "system" table

CodeLet: 

/**
* Implements hook_form_FORM_ID_alter().
*/
function MY_MODULE_form_commerce_cart_add_to_cart_form_alter(&$form, &$form_state, $form_id) {
$form['submit']['']['value'] = t('Buy Now');
$form[''][] = '_custom_redirect_checkout';
}

/**
* add to card submit form handler
* @param unknown $form
* @param unknown $form_state
*/
function _custom_redirect_checkout($form, &$form_state) {
drupal_goto('checkout');
}

By saru1683 on Tue, 02/06/2015 - 5:20pm

Add comment

Log in or register to post comments
QR code for this page URL This page URL
Feedback