3

I am using Commerce Donate and configured it to show donation form on checkout page. That is what actually I need. Donation form, contact info and payment form on same page.

But we cannot go to the checkout page without having some product in cart.

How can I do that?

2

You can add the following code to a custom module:

/**
 * Implements hook_menu_alter().
 */
function YOURMODULE_menu_alter(&$items) {
  // Alter the default checkout callback to allow checkout without products.
  $items['checkout']['page callback'] = 'YOURMODULE_checkout_router';
}

/**
 * Implements hook_commerce_checkout_order_can_checkout().
 */
function YOURMODULE_commerce_checkout_order_can_checkout($order) {
  return TRUE;
}

/**
 * Displays the checkout form and create the user a cart if none exist.
 */
function YOURMODULE_checkout_router() {
  global $user;
  // Load the shopping cart order.
  if (!($order = commerce_cart_order_load($user->uid))) {
    $order = commerce_cart_order_new();
  }
  drupal_goto('checkout/' . $order->order_id);
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.