DUPLICATE: Product badge "New" for query Loop

There have been a few posts about this but no member of the Bricks team has ever responded.

That’s why I’m posting this here as a bug because it’s not usable.

Or are we missing something?

How do you use the “New” badge that you can customize in the Bricks settings? There is no dynamic data tag for it.

Hi @tobiashaas,

As you know, this is not a bug. Because the option in the Bricks settings is implemented for the products element. So with permission from the Bricks team I’m changing this topic to “Feature Request”. There is also already a request for it here.

As a workaround, you can use the following code to achieve this.

function is_product_new($days = 30, $product_id = null) {
    if (!$product_id) {
        $product_id = get_the_ID();
    }
    $publish_date = get_the_date('Y-m-d', $product_id);
    $publish_timestamp = strtotime($publish_date);
    $current_timestamp = current_time('timestamp');
    $date_diff = ($current_timestamp - $publish_timestamp) / (60 * 60 * 24);
    return $date_diff <= $days ? 1 : 0;
}

in bricks conditions set :

{echo:is_product_new(3)}
==
1

In the dynamic data above, consider 3 as the number of days.

Good luck,
HOSEIN