2

How to add the popup(when you click on delete item) to a custom button, Screenshot Belowcart Pop up

    <?php
$orderStatus = $_order->getStatusLabel();

if ($orderStatus == 'Pending' || $orderStatus == 'Processing')
    {
?>
   <a href="<?php /* @escapeNotVerified */
    echo $block->getBaseUrl() . 'ordercancel/index/ordercancel?orderId=' .       $_order->getId(); ?>" class="action view">
    <span><?php /* @escapeNotVerified */
    echo __('Cancel Order') ?></span>
                                </a>
                            <?php
    } ?>

Want to add this popup when customer click order cancel

  • Its default functionality of magento 2. – Rakesh Jesadiya Oct 24 '16 at 10:58
  • How to use it in my custom button – Vishwas Bhatnagar Oct 24 '16 at 10:59
  • please share your code to check. – Rakesh Jesadiya Oct 24 '16 at 11:00
  • @Rakesh Updated code , i was looking for how magento implemented using KO – Vishwas Bhatnagar Oct 24 '16 at 11:07
  • inside frontend or backend? – Rakesh Jesadiya Oct 24 '16 at 11:09
1

You can try with below code,

require(['jquery','Magento_Ui/js/modal/confirm'], function ($, confirm) {
    $('.view').on("click",function(event){
        event.stopPropagation();
        getId = $(this).attr('data-order');
        confirm({
            content: 'Are you sure you would like to remove this item from the shopping cart?',
            actions: {
                confirm: function () {
                    _removeItem(getId);
                },
                always: function (event) {
                    event.stopImmediatePropagation();
                }
            }
        });
    });

    function _removeItem(orderId) {
            var itemId = orderId;
            //ajax call here..
    },
 }

data-order with order id is added in anchor tag.

<a href="<?php /* @escapeNotVerified */
echo $block->getBaseUrl() . 'ordercancel/index/ordercancel?orderId=' .       $_order->getId(); ?>" class="action view" data-order="<?php echo $_order->getId(); ?>">
<span><?php /* @escapeNotVerified */
echo __('Cancel Order') ?></span>
                            </a>
  • how to do the same in cart ... – sangan Nov 27 '17 at 9:40

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.