VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: Ferran on May 16, 2023, 11:38:38 AM

Title: Remove product button in modal cart popup (padded.php)
Post by: Ferran on May 16, 2023, 11:38:38 AM
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!
Title: Re: Remove product button in modal cart popup (padded.php)
Post by: Ferran on May 16, 2023, 17:21:04 PM
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>';