Quantcast
Channel: Drupal Developer - Drupal commerce
Viewing all articles
Browse latest Browse all 4

Drupal: Commerce buy now

$
0
0

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: 

<?php
/**
* 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');
}
?>

Is CodeLet useful?: 
Compatibility: 

Viewing all articles
Browse latest Browse all 4

Trending Articles