[Resolved] New badge for WooCommerce

Home Forums Support [Resolved] New badge for WooCommerce

Home Forums Support New badge for WooCommerce

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #661911
    Katja

    Hello GeneratePress Team,

    we have Woocommerce up and running and have the sale flash activated via the customizer (display over the inage).

    Is it possible to display a flash for new products, say added within the last thirty days, via a hook? Ieally this would float to the left (the sale flash floats to the right) also over the image.

    Any pointers would be appreciated. Is this something that imght usefully be added to the GP WooCommerce offering in future?

    Thanks for any help and best wishes to you all

    Roger

    GeneratePress 2.1.4
    GP Premium 1.7.2
    #662079
    David
    Staff
    Customer Support

    Hi there,

    so the only up to date plugin (aside of Codecanyon) is:

    https://woocommerce.com/products/woocommerce-advanced-product-labels/

    Or you can code it in using this function:

    add_action( 'woocommerce_before_shop_loop_item_title', function() {
    	$postdate      = get_the_time( 'Y-m-d' ); // Post date
    	$postdatestamp = strtotime( $postdate );  // Timestamped post date
    	$newness       = 30;                      // Newness in days
    	if ( ( time() - ( 60 * 60 * 24 * $newness ) ) < $postdatestamp ) {
    		echo '<div class="woo-entry-new-badge">' . esc_html__( 'New', 'total' ) . '</div>';
    	}
    }, 20 );

    You can change the woocommerce_before_shop_loop_item_title hook if you wish. A visual hook guide link below. And the woo-entry-new-badge class can be used to style it.

    https://businessbloomer.com/woocommerce-visual-hook-guide-archiveshopcat-page/

    I’ll make Tom aware of the possible feature request ๐Ÿ™‚

    #662307
    Katja

    Hello David,

    thank you for the helpful pointers. Gives me something to get me teeth into.

    Best wishes

    #662309
    David
    Staff
    Customer Support

    You’re welcome. ๐Ÿ™‚

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