Files
mccans-theme/actions/WooCommerceProductTile.php
2025-06-25 16:04:19 -07:00

33 lines
728 B
PHP

<?php
namespace Actions;
use Helpers\McCansHelpers;
use ofc\RadAction;
class WooCommerceProductTile extends RadAction
{
protected string $hookName = "woocommerce_shop_loop_item_title";
protected bool $wrapInit = true;
public function callback()
{
global $product;
$data = site()->getPost($product->id, [
"url",
"id",
"title",
"thumbnail",
"woocommerce.price",
"woocommerce.attribute.msrp",
"woocommerce.cartUrl",
"woocommerce.sku",
]);
$data["savings"] = McCansHelpers::calcDifference($data["price"], $data["msrp"]);
echo site()->render("product-tile", $data);
}
}