Files
mccans-theme/actions/WooCommerceCategoryLayout.php
2025-07-18 15:35:53 -07:00

49 lines
1.2 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",
"acf.top_image",
]));
$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);
}
// little inline style booger
if ($type === "both") {
echo site()->render("hideSubCatsForBoth");
}
echo site()->render('woocommerce-before-content');
}
}