Remove product button in modal cart popup (padded.php)

Started by Ferran, May 16, 2023, 11:38:38 AM

Previous topic - Next topic

Ferran

Hello, is that any easy way to add a button for delete the product that just added to the cart in the modal popup padded.php?

Thanks!

Ferran

i created this, it works but only if there are only one product in the cart, if there are different products it delete the other product, not the most recently added. Any idea???

// Function to generate the URL for deleting a product from the cart
function getDeleteFromCartURL($productId) {
    $url = JURI::base() . 'index.php?option=com_virtuemart&view=cart&task=delete&virtuemart_product_id=' . $productId;
    return $url;
}

      // Add the delete button for each product
        $deleteURL = getDeleteFromCartURL($key); // Utilizar $key como identificador del producto en el carrito
        echo '<a class="' . $vmbtn . ' ' . $vmbtnsec . ' delete_product_button" href="' . $deleteURL . '">' . vmText::_('COM_VIRTUEMART_CART_DELETE') . '</a>';