2

I've used Bodak Module :https://github.com/sbodak/magento2-checkout-custom-form

And I changed the checkout to my liking.

How can I add the spaces between the text "If you don't have the code, you can skip this step." and the textbox?

I tried with css but it also changes those above.

Thanks!

enter image description here

asked Mar 21, 2019 at 22:13

2 Answers 2

1

You can override that template file at app/design/frontend/<Theme Vendor>/<Theme Name>/Bodak_CheckoutCustomForm/view/frontend/templates/order/view/custom_fields.phtml. This is a better approach than editing the file directly as your changes will be overwritten if you ever decide to update this module.

As for the file:

<?php
/** @var Bodak\CheckoutCustomForm\Block\Order\CustomFields $block */
/** @var Bodak\CheckoutCustomForm\Model\Data\CustomFields $customFields */
$customFields = $block->getCustomFields($block->getOrder());
?>
<?php if($customFields): ?>
 <div class="block block-order-details-view">
 <div class="block-content">
 <div class="box">
 <strong class="box-title"><span><?php /* @escapeNotVerified */ echo __('Other information') ?></span></strong>
 <div class="box-content">
 <strong><?php /* @escapeNotVerified */ echo __('Buyer') ?>:</strong>
 <?php echo $this->escapeHtml($customFields->getCheckoutBuyerName()); ?><br>
 <strong><?php /* @escapeNotVerified */ echo __('Buyer email address') ?>:</strong>
 <?php echo $this->escapeHtml($customFields->getCheckoutBuyerEmail()); ?><br>
 <strong><?php /* @escapeNotVerified */ echo __('Purchase order no.') ?>:</strong>
 <?php echo $this->escapeHtml($customFields->getCheckoutPurchaseOrderNo()); ?><br>
 <strong><?php /* @escapeNotVerified */ echo __('Goods mark') ?>:</strong>
 <?php echo $this->escapeHtml($customFields->getCheckoutGoodsMark()); ?>
 </div>
 </div>
 <div class="box">
 <strong class="box-title"><span><?php /* @escapeNotVerified */ echo __('Comment') ?></span></strong>
 <div class="box-content" style="margin-bottom: 20px"> <?php /*Just add your CSS inline to the specific container you want to add spacing below.*/ ?>
 <?php echo nl2br($this->escapeHtml($customFields->getCheckoutComment())); ?>
 </div>
 </div>
 </div>
 </div>
<?php endif; ?>

If you can post your updated code here so I can see it, I'll show you exactly what to change.

answered Mar 22, 2019 at 0:36
0

You can modify view/frontend/templates/order/view/custom_fields.phtml. It is the one responsible for rendering your custom field in the checkout page.
Check below modified code (I have added a <br> on top of the custom comment):

<?php
/** @var Bodak\CheckoutCustomForm\Block\Order\CustomFields $block */
/** @var Bodak\CheckoutCustomForm\Model\Data\CustomFields $customFields */
$customFields = $block->getCustomFields($block->getOrder());
?>
<?php if($customFields): ?>
 <div class="block block-order-details-view">
 <div class="block-content">
 <div class="box">
 <strong class="box-title"><span><?php /* @escapeNotVerified */ echo __('Other information') ?></span></strong>
 <div class="box-content">
 <strong><?php /* @escapeNotVerified */ echo __('Buyer') ?>:</strong>
 <?php echo $this->escapeHtml($customFields->getCheckoutBuyerName()); ?><br>
 <strong><?php /* @escapeNotVerified */ echo __('Buyer email address') ?>:</strong>
 <?php echo $this->escapeHtml($customFields->getCheckoutBuyerEmail()); ?><br>
 <strong><?php /* @escapeNotVerified */ echo __('Purchase order no.') ?>:</strong>
 <?php echo $this->escapeHtml($customFields->getCheckoutPurchaseOrderNo()); ?><br>
 <strong><?php /* @escapeNotVerified */ echo __('Goods mark') ?>:</strong>
 <?php echo $this->escapeHtml($customFields->getCheckoutGoodsMark()); ?>
 </div>
 </div>
 <div class="box">
 <strong class="box-title"><span><?php /* @escapeNotVerified */ echo __('Comment') ?></span></strong>
 <div class="box-content">
 <br/> /** This will add br space */
 <?php echo nl2br($this->escapeHtml($customFields->getCheckoutComment())); ?>
 </div>
 </div>
 </div>
 </div>
<?php endif; ?>
answered Mar 21, 2019 at 22:37
3
  • Thanks for your reply. I tried to add but it doesn't work, nothing has changed. I made the reindex, cleaned the cache etc etc Commented Mar 21, 2019 at 23:31
  • did you run setup upgrade first then redeploy static content? Commented Mar 21, 2019 at 23:59
  • if you can provide us your exact code it would be easier for us to help you Commented Mar 22, 2019 at 1:06

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.