shop changes

This commit is contained in:
2025-06-25 16:04:19 -07:00
parent 8d33ce2dc7
commit b0635919b1
30 changed files with 550 additions and 144 deletions

View File

@@ -0,0 +1,20 @@
<?php
namespace Actions;
use ofc\RadAction;
class WooCommerceAfterContent extends RadAction
{
protected string $hookName = "woocommerce_after_main_content";
protected int $priority = 50;
public function callback()
{
if (is_product()) {
return;
}
echo site()->render('woocommerce-after-content');
}
}

View File

@@ -0,0 +1,16 @@
<?php
namespace Actions;
use ofc\RadAction;
class WooCommerceAfterProductSummary extends RadAction
{
protected string $hookName = "woocommerce_after_single_product_summary";
protected int $priority = 0;
public function callback()
{
echo site()->render('woocommerce-before-content');
}
}

View File

@@ -0,0 +1,18 @@
<?php
namespace Actions;
use ofc\RadAction;
class WooCommerceBeforeProductSummary extends RadAction
{
protected string $hookName = "woocommerce_before_single_product_summary";
protected int $priority = 0;
public function callback()
{
echo site()->render('woocommerce-before-content', [
"additionalTopLevelClass" => "single-product-top",
]);
}
}

View File

@@ -0,0 +1,45 @@
<?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');
}
}

View File

@@ -0,0 +1,30 @@
<?php
namespace Actions;
use ofc\RadAction;
class WooCommerceCategoryLayoutHideProducts extends RadAction
{
protected string $hookName = "woocommerce_before_main_content";
public function callback()
{
if (!is_product_category()) {
return;
}
$type = site()->getQueriedObject(null, ['display_type']);
if ($type === "") {
$type = "products";
} else {
$type = $type["display_type"];
}
if ($type != "subcategories") {
return;
}
echo site()->render("hideProducts");
}
}

View File

@@ -0,0 +1,20 @@
<?php
namespace Actions;
use ofc\RadAction;
class WooCommerceCleanup extends RadAction
{
protected string $hookName = "init";
protected int $priority = 5;
public function callback()
{
remove_all_actions('woocommerce_before_shop_loop_item');
remove_all_actions('woocommerce_before_shop_loop_item_title');
remove_all_actions('woocommerce_shop_loop_item_title');
remove_all_actions('woocommerce_after_shop_loop_item_title');
remove_all_actions('woocommerce_after_shop_loop_item');
}
}

View File

@@ -0,0 +1,15 @@
<?php
namespace Actions;
use ofc\RadAction;
class WooCommerceProductSummary extends RadAction
{
protected string $hookName = "woocommerce_single_product_summary";
public function callback()
{
echo site()->render('woocommerce-after-content');
}
}

View File

@@ -0,0 +1,32 @@
<?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);
}
}

View File

@@ -0,0 +1,26 @@
<?php
namespace Actions;
use ofc\RadAction;
class WooCommerceShopLayout extends RadAction
{
protected string $hookName = "woocommerce_before_main_content";
protected int $priority = 5;
public function callback()
{
if (!is_shop()) {
return;
}
// shop page
echo site()->render("shop-top", site()->getPost(wc_get_page_id('shop'), [
"headline",
"intro_text",
"thumbnail",
]));
echo site()->render('woocommerce-before-content');
}
}