WIP
This commit is contained in:
@@ -1,15 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace Helpers;
|
||||
|
||||
class DateFormatter
|
||||
{
|
||||
public static function monthDayYear()
|
||||
{
|
||||
return function ($template, $context, $args, $source) {
|
||||
$dateString = strtotime($context->get($args));
|
||||
|
||||
return date("M d, Y", $dateString);
|
||||
};
|
||||
}
|
||||
}
|
||||
52
helpers/McCansHelpers.php
Normal file
52
helpers/McCansHelpers.php
Normal file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
|
||||
namespace Helpers;
|
||||
|
||||
class McCansHelpers
|
||||
{
|
||||
public static function testimonial()
|
||||
{
|
||||
return function ($template, $context, $args, $source) {
|
||||
$post = $context->get($args);
|
||||
return site()->render('testimonial-block', site()->getPost($post, [
|
||||
'title',
|
||||
'thumbnail',
|
||||
'position',
|
||||
'quote',
|
||||
'rating',
|
||||
]));
|
||||
};
|
||||
}
|
||||
|
||||
public static function locationTile()
|
||||
{
|
||||
return function ($template, $context, $args, $source) {
|
||||
return site()->render("location-tile", $context->get($args));
|
||||
};
|
||||
}
|
||||
|
||||
public static function productTile()
|
||||
{
|
||||
return function ($template, $context, $args, $source) {
|
||||
$data = site()->getPost($context->get($args), [
|
||||
"title",
|
||||
"thumbnail",
|
||||
"url",
|
||||
"woocommerce.price",
|
||||
"woocommerce.cartUrl",
|
||||
"woocommerce.attribute.msrp",
|
||||
]);
|
||||
if ((float) $data["msrp"] && (float) $data["price"]) {
|
||||
if ($data["price"] != 0) {
|
||||
$difference = $data["msrp"] - $data["price"];
|
||||
if ($difference > 0) {
|
||||
$savingsPercent = round(($difference / $data["msrp"])*100);
|
||||
}
|
||||
|
||||
$data["savings"] = $savingsPercent;
|
||||
}
|
||||
}
|
||||
return site()->render("product-tile", $data);
|
||||
};
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user