Confirmation popup on 'Remove' button

EpotratzEpotratz Member
in Help edited February 3
Guys guys,

We have some customers removing the child-item, which removes the subscription from the order, even though they actually want the subscription.

We'd like to apply a browser pop-up message to the child-item 'Remove' button, like this:

image



As an example, we have a little browser message that shows on our blog when users click the "Store" link. Could something like this be applied to that child "Remove" button?

jQuery.noConflict();
jQuery(document).ready(function(){
var menuID = jQuery('#menu-item-218');

findA = menuID.find('a');

findA.click(function(event){
if(confirm("You are about to leave this informational blog to enter the Botanical Craft webstore."))
{
window.open('https://botanicalcraft.com','_blank'); //This will open the website in a new tab
}

Comments
  • fc_adamfc_adam FoxyCart Team
    @Epotratz,

    You can certainly add in some custom javascript there to show an alert. Perhaps an easier solution could be to simply remove the remove link for that product using CSS - so people can't remove it directly.

    For handling it with javascript, that would look like this:
    FC.client.on("cart-item-remove", function(params) {
    var is_sub = false;
    for (var i = FC.json.items.length - 1; i >= 0; i--) {
    if (FC.json.items[i].id == params.id && FC.json.items[i].sub_frequency != "") {
    is_sub = true;
    }
    }

    if (is_sub) {
    return confirm("You are about to remove the recurring autoship from this order. Are you sure?");
    } else {
    return true;
    }
    });
  • @fc_adam

    Thanks for that.

    I'm guessing this would only target the "Remove" button for items with a sub_frequency or 2:sub_frequency?

  • fc_adamfc_adam FoxyCart Team
    @Epotratz,

    That's correct - it is only applying to a product with a sub_frequency set, but you can certainly customise the logic to apply to other products too if needed.
Sign In or Register to comment.