0

When I click on item "edit link" modal popup is open but when i edit other product it will show previous product data.

Can anyone help to get dynamic popup with dynamic data in per different products?

Please refer screenshots below:

enter image description here

enter image description here

1
  • Update the code which you have tried to your question. Dec 19, 2018 at 8:57

1 Answer 1

1

You need to customize edit.phtml file to achieve it. To customize the item renderer file, you can copy edit.phtml file from

vendor/magento/module-checkout/view/frontend/templates/cart/item/renderer/actions/edit.phtml

to your custom theme.

add dynamic id to edit link by using below code:

<?php $_item = $block->getItem(); ?>

<?php if ($block->isProductVisibleInSiteVisibility()): ?>
    <a id="your_id_<?php echo $_item->getItemId(); ?>" class="action action-edit"
       href="<?= /* @escapeNotVerified */ $block->getConfigureUrl() ?>"
       title="<?= $block->escapeHtml(__('Edit item parameters')) ?>">
        <span>
            <?= /* @escapeNotVerified */ __('Edit') ?>
        </span>
   </a>
<?php endif ?>

<script type="text/javascript">
require(['jquery'],
    function ($) {
        var quote_item_id = "<?php echo $_item->getItemId(); ?>";
        $(document).on('click', '#your_id_' + quote_item_id, function (e) {
            //code to open your modal popup
        }
    });
</script>

Now trigger popup modal on click of this id.

I hope it will help you out, let me know in case any doubt.

2
  • I have been struggling for this from last few hours and you solve my problem thanks. +1.
    – Mehran
    Jun 3, 2021 at 11:19
  • Welcome @Mehran! Jun 3, 2021 at 13:08

Your Answer

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

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