• Resolved masoud4x4

    (@masoud2018)


    jQuery(document).ready(function($) {
    var notice = $(".woocommerce-message, .woocommerce-error, .woocommerce-info");
    
    if (notice.length > 0) {
        var message = notice.html();
        var type = notice.hasClass("woocommerce-error") ? "error" : notice.hasClass("woocommerce-message") ? "success" : "";
    
        $("#woocommerce-popup").addClass(type);
        $("#woocommerce-popup .popup-content").html(message);
        $("#woocommerce-popup").fadeIn();
    
        setTimeout(function() {
            $("#woocommerce-popup").fadeOut();
        }, 5000);
    }
    
    $(".close-popup").click(function() {
        $("#woocommerce-popup").fadeOut();
    });});

    With this code, everything is fine, as long as I have the code in the file woocommerce.php

    <?php  wc_print_notices(); ?>

    which in this case, both in ajax and in the default notification, the phrase “product added to cart” is displayed, and as soon as I delete exactly everything returns to the default WooCommerce state, that is, a message appears at the top of the product tabs and there is no longer any news of showing the custom message.How do I tell WooCommerce to use a custom message instead of my default message?

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support Moses M. (woo-hc)

    (@mosesmedh)

    Hi @masoud2018,

    I’m not entirely clear on your request. It would be helpful if you could provide more details about what you’re trying to accomplish and the issue you’re facing. Sharing a screenshot to highlight what you’re referring to would also help me better understand your request.

    Thread Starter masoud4x4

    (@masoud2018)

    Thank you so much for your response.

    My goal is to create a pop-up notification, similar to the attached image (Image 1). However, due to the bulkiness of plugins and the fact that my needs are relatively simple, I want to build a basic version with code so that all alerts, success messages, and error messages are displayed in it.

    During my research, I realized that the function <?php wc_print_notices(); ?> must be in the woocommerce.php file, otherwise, you cannot get output from the above commands and control it. In simpler terms, without the mentioned function, the messages are displayed in a default location on the product page. But when this function is present, WooCommerce returns one message in the pop-up and another where the function is placed within the code, resulting in two messages (Image 1 and 2) on one page. Please correct me if I’m wrong. Is the only way to prevent the default WooCommerce message from being displayed to use CSS and hide it?

    The only problem I’m facing is that although the alerts appear in the product page pop-up, error messages do not appear in this box on the checkout page (Image 3). Can you guide me on how to accomplish this?

    Plugin Support Moses M. (woo-hc)

    (@mosesmedh)

    Hi @masoud2018,

    I understand that you’re looking to customize your site and adjust certain features. However, this request is beyond the support scope of this forum.

    Our primary focus here is to assist with core WooCommerce issues and concerns. For customization, I recommend reaching out to WooExperts, hiring a professional from codeable.io, or using the Community Slack channel for further help.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.