53 lines
1.5 KiB
PHP
53 lines
1.5 KiB
PHP
<?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);
|
|
};
|
|
}
|
|
}
|