After updating Woocomerce, a lot of unnecessary code appeared in the code

This topic has 11 replies, 3 voices, and was last updated 1 years ago ago by Andrew Mitchell

  • Avatar: Goostaf
    Goostaf
    Participant
    November 27, 2024 at 09:03

    Hello, we tried not to touch this plugin, but we had to update it and a lot of unnecessary information came out from the product cards, as far as I understood, it stretches from screen-reader-text, before we just deleted the code with your help from the file quantity-input.php ( in quantity-input.php ), but now the file has completely changed and there is no such code, how do we now delete all this extra piece of code?

    Files is visible for topic creator and
    support staff only.
    10 Answers
    Avatar: Justin
    Luca Rossi
    Support staff
    November 27, 2024 at 16:05

    Dear @Goostaf,

    We hope this message finds you well.

    Could you kindly try reverting to an earlier version of the WooCommerce plugin? Please note that the screen-reader-text HTML is generated by the WooCommerce plugin itself and not by our XStore theme or XStore Core plugin.

    Should you require any further assistance, please do not hesitate to reach out.

    Best regards,
    The 8Theme Team

    Avatar: Goostaf
    Goostaf
    Participant
    November 28, 2024 at 10:00

    I don’t even know what version you had, you updated our Woocomerce plugin.

    Avatar: Justin
    Luca Rossi
    Support staff
    November 28, 2024 at 10:35

    Dear @Goostaf,

    Thank you for reaching out to us.

    We would like to clarify that our team does not update any themes or plugins unless specifically requested by our customers.

    In this instance, we kindly recommend restoring a recent backup of your website to address the issue.

    Should you require further assistance, please do not hesitate to contact us.

    Best regards,
    The 8Theme Team

    Avatar: Goostaf
    Goostaf
    Participant
    November 28, 2024 at 11:05

    I just wrote in the last thread that there were errors in the button, you solved the problem and the plugin was updated, I have not updated it specifically for probably half a year:)

    Anyway, maybe you can help here? So that I don’t rollback, but update as it should be further? I don’t know what the file code was before, but I know for sure that removing the code here is what you seem to have done for me in past threads:

    //label class=“screen-reader-text” for=“”> in quantity-input.php//

    everything worked fine. I.e. we apparently removed all this unnecessary stuff from the code via screen-reader-text, a bunch of garbage in the code, which throws us off the whole relevance of the document type:

    //span class=“screen-reader-text”//The original price was, Current price: 2990 ₽.// all this style is not needed absolutely, the file itself quantity-input.php is not large, can you tell me what can be commented or changed?

    Avatar: Goostaf
    Goostaf
    Participant
    November 28, 2024 at 11:08

    screen

    Files is visible for topic creator and
    support staff only.
    Avatar: Goostaf
    Goostaf
    Participant
    November 28, 2024 at 17:12

    This is the solution neuron offered us in function:

    // Remove text output for screen-reader.
    add_filter(‘woocommerce_get_price_html’, ‘remove_screen_reader_text_from_prices’, 10, 2);

    function remove_screen_reader_text_from_prices($price, $product) {
    // Remove screenreader text using a regular expression.
    $price = preg_replace(‘/.*?<\/span>/’, ”, $price);
    return $price;
    }
    It kind of removes the piece, but still in the card pulls texts like: “ data-product_sku=”56777“ rel=”nofollow“ data-success_message=”“A set of balls "Cream Heart"” added to your cart“>” Why they have all this, I do not understand, I do not even know what to do, rollback, but is it safe?

    Avatar: Goostaf
    Goostaf
    Participant
    November 28, 2024 at 17:54

    We got 2 codes:

    // Remove text output for screen-reader.
    add_filter(‘woocommerce_get_price_html’, ‘remove_screen_reader_text_from_prices’, 10, 2);
    function remove_screen_reader_text_from_prices($price, $product) {
    // Remove screenreader text using a regular expression.
    $price = preg_replace(‘/.*?<\/span>/’, ”, $price);
    return $price;
    }
    add_filter( ‘woocommerce_loop_add_to_cart_args’, ‘clear_success_message_attribute’, 10, 2 );
    function clear_success_message_attribute( $args, $product ) {
    // Clear the contents of the data-success_message attribute.
    if ( isset( $args[‘attributes’][‘data-success_message’] ) ) ) {
    $args[‘attributes’][‘data-success_message’] = ”; // Empty value.
    }
    return $args;
    }
    and it seems to work, will it harm the site?

    Avatar: Goostaf
    Goostaf
    Participant
    November 28, 2024 at 17:55

    If you have a different solution and a better one, I would be very happy!

    Avatar: Justin
    Luca Rossi
    Support staff
    November 29, 2024 at 04:54

    Hi @Goostaf,

    The following codes look good. You can keep using them:

    
    // Remove text output for screen-reader.
    add_filter('woocommerce_get_price_html', 'remove_screen_reader_text_from_prices', 10, 2);
    function remove_screen_reader_text_from_prices($price, $product) {
        // Remove screenreader text using a regular expression.
    	$price = preg_replace('/.*?<\/span>/', '', $price);
        return $price;
    }
    add_filter( 'woocommerce_loop_add_to_cart_args', 'clear_success_message_attribute', 10, 2 );
    function clear_success_message_attribute( $args, $product ) {
        // Clear the contents of the data-success_message attribute.
    	if ( isset( $args['attributes']['data-success_message'] ) ) ) {
    		$args['attributes']['data-success_message'] = ''; // Empty value.
    	}
        return $args;
    }
    

    Best regards,
    The 8Theme Team

    Avatar: Andrew Mitchell
    Andrew Mitchell
    Support staff
    November 29, 2024 at 09:17

    Dear Goostaf,

    We hope you’re reveling in the experience our theme brings! Your enthusiasm is what fuels our passion. Would you be so kind as to channel that energy into a 5-star rating on ThemeForest? Your feedback is the spark that lights our way!

    Click here to spread the love: https://themeforest.net/downloads

    Thank you for being an integral part of our journey!

    Best Regards,
    The 8Theme Team

  • Viewing 11 results - 1 through 11 (of 11 total)

The issue related to '‘After updating Woocomerce, a lot of unnecessary code appeared in the code’' has been successfully resolved, and the topic is now closed for further responses

We're using our own and third-party cookies to improve your experience and our website. Keep on browsing to accept our cookie policy.