2

When I try to delete additional address in Magento 2 customer dashboard its redirecting to 404 Page. My URL format mentioned below.

/customer/address/delete/id/13/form_key/xkTKVSSxqip79bZ1
3

I got the solution. Change 'HttpPostActionInterface' with 'HttpGetActionInterface'.

vendor/magento/module-customer/Controller/Address/delete.php use Magento\Framework\App\Action\HttpGetActionInterface as HttpGetActionInterface;

class Delete extends \Magento\Customer\Controller\Address implements HttpGetActionInterface

  • Interestingly even with HttpPostActionInterface, it works from grid delete URL but not from the edit form section. – Adarsh Khatri Aug 8 at 0:54
0

It depends on what version of Magento 2 you are.

See this commit on GitHub. It added a check to enforce the request to be done with POST method. The default js code will send the request trough a POST request.

I don't see why your code does not work or how you're calling that GET request. But I would recommend simply changing your template to use a form instead of an anchor element.

<form action="<?php echo $block->getUrl("*/*/delete") ?>" method="POST">
    <?= $block->getBlockHtml('formkey') ?>
    <input type="hidden" name="id" value="<?= $_address->getId() ?>">
    <button type="submit">
        <?php echo $block->escapeHtml(__('Delete')) ?>
    </button>
</form>

Obviously some styling will be needed.

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.