0

I have made a form_alter in template.php in my theme and I have created a custom page (page--checkout.tpl.php) to render my form. If I render the content as print render($page['content']); everything is fine, but I want to print the cart content on the top of the page, and the customer_profile_billing and commerce_payment below the cart contents in two seaprate columns. How can i call for these seperate panes in the page--checkout.tpl.php in order to show them the way I need?

I've searched everywhere but it seems that I cannot find something that works for my needs.

Thank you in advance everybody.

0

Well it might seem a little noobish mistake but nevertheless, for everyone that is interested out there.

After a lot of research I found out how to make it.

The problem that arises when you try to render a form in a .tpl file is the functionality of the form.

I was trying to render $page['content'] and I couldn't do the above.

So I had to add to MYTHEME\template.php these lines:

function MYTHEME_theme($existing, $type, $theme, $path) {
  return array(
    'commerce_checkout_form_checkout' => array(
      'render element' => 'form',
      'template' => 'commerce-checkout-form-checkout',
      'path' => drupal_get_path('theme', 'MYTHEME') . '/template/forms',
    ),
  );
}

and then I created: commerce-checkout-form-checkout.tpl.php in MYTHEME/template/forms

and I just put this code inside:

<div class="row">
  <div class="col-sm-12"><?php print render($form['cart_contents']); ?></div>
</div>
<div class="row">
  <div class="col-sm-6"><?php print render($form['customer_profile_billing']); ?></div>
  <div class="col-sm-6"><?php print render($form['commerce_payment']); ?></div>
</div>
<?php print drupal_render_children($form); ?>

The key to render the form right was the last line:

<?php print drupal_render_children($form); ?>

which rendered all the missing funcionality (like ajax and submit buttons) from the form.

I hope this will help someone in the future to avoid all the time and hassle..

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.