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

46 lines
1.1 KiB
PHP

<?php
namespace Actions;
use ofc\RadAction;
class WooCommerceCategoryLayout extends RadAction
{
protected string $hookName = "woocommerce_before_main_content";
protected int $priority = 5;
public function callback()
{
if (!is_product_category()) {
return;
}
echo site()->render("shop-category-slice", site()->getQueriedObject(null, [
"title",
"description",
"thumbnail",
"url",
"acf.intro_headline",
"acf.intro_content",
]));
$type = site()->getQueriedObject(null, ['display_type']);
if ($type === "") {
$type = "products";
} else {
$type = $type["display_type"];
}
if ($type === "both" || $type === "subcategories") {
$childCats = site()->getQueriedObject(null, ["children.url,thumbnail,title,count"]);
echo site()->render("shop-sub-categories", $childCats);
}
if ($type === "both" || $type === "products") {
// die("why?");
}
echo site()->render('woocommerce-before-content');
}
}