Adding If statements to templates
-
Hi, So we added a custom field to our stores to add a date. We want to remove a badge that displays that its “fresh product” on our template after 30days goes by. I wrote the falling php code to do this, however I can’t seem to get it to work. I’m reaching out to all you smart php coders that could give me some pointers on what I’m doing wrong! Thanks for your help in advance!
The code in functions.php:
if(strtotime(date('m-d-Y')) > strtotime('+30 days', strtotime('<%= fresh_drop_date %>'))) { $listing_template .= "\t\t\t" . '<p class="fresh-date" ><%= fresh_drop_date %></p>' . "\r\n"; } else { $listing_template .= "\t\t\t" . '<% if ( fresh_drop_date ) { %>' . "\r\n"; $listing_template .= "\t\t\t" . '<div class="fresh-img"></div>' . "\r\n"; $listing_template .= "\t\t\t" . '<p class="fresh-date"> <%= fresh_drop_date %> </p>' . "\r\n"; $listing_template .= "\t\t\t" . '<% } %>' . "\r\n"; }
The page I need help with: [log in to see the link]
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘Adding If statements to templates’ is closed to new replies.