2

Currently Billing and Shipping address don't have checkboxes to select, to change it from Billing to Shipping or Shipping to Billing. It only shows a message info.

So, I want to be checkboxes as same as an additional address form. So that user change

Billing Address -> Shipping Address

Shipping Address -> Billing Address

The problem is how can I get the Use as my default billing address checkbox selected when the user edits Billing Address and vice versa for Shipping Address.

Old Code

 <?php if ($block->isDefaultBilling()): ?>
        <div class="message info">
            <span><?= $block->escapeHtml(__("It's a default billing address.")) ?></span>
        </div>
    <?php elseif ($block->canSetAsDefaultBilling()): ?>
        <div class="field choice set shipping">
            <input type="checkbox" id="primary_billing" name="default_billing" value="1" class="checkbox">
            <label class="label" for="primary_billing">
                <span><?= $block->escapeHtml(__('Use as my default billing address')) ?></span>
            </label>
        </div>
    <?php else: ?>
        <input type="hidden" name="default_billing" value="1">
    <?php endif; ?>
      <input type="hidden" name="default_billing" value="1" />
  <?php endif; ?>

Changed Code

 <?php if ($block->isDefaultBilling()): ?>
        <div class="field choice set billing">
            <input type="checkbox" id="primary_billing" name="default_billing" value="1" class="checkbox">
            <label class="label" for="primary_billing">
                <span><?= $block->escapeHtml(__('Use as my default billing address')) ?></span>
            </label>
        </div>
    <?php elseif ($block->canSetAsDefaultBilling()): ?>
        <div class="field choice set billing">
            <input type="checkbox" id="primary_billing" name="default_billing" value="1" class="checkbox">
            <label class="label" for="primary_billing">
                <span><?= $block->escapeHtml(__('Use as my default billing address')) ?></span>
            </label>
        </div>
    <?php else: ?>
     <input type="hidden" name="default_billing" value="1" />
  <?php endif; ?>

Your Answer

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

Browse other questions tagged or ask your own question.