shop changes
This commit is contained in:
20
actions/WooCommerceAfterContent.php
Normal file
20
actions/WooCommerceAfterContent.php
Normal 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');
|
||||
}
|
||||
}
|
||||
16
actions/WooCommerceAfterProductSummary.php
Normal file
16
actions/WooCommerceAfterProductSummary.php
Normal 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');
|
||||
}
|
||||
}
|
||||
18
actions/WooCommerceBeforeProductSummary.php
Normal file
18
actions/WooCommerceBeforeProductSummary.php
Normal 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",
|
||||
]);
|
||||
}
|
||||
}
|
||||
45
actions/WooCommerceCategoryLayout.php
Normal file
45
actions/WooCommerceCategoryLayout.php
Normal 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');
|
||||
}
|
||||
}
|
||||
30
actions/WooCommerceCategoryLayoutHideProducts.php
Normal file
30
actions/WooCommerceCategoryLayoutHideProducts.php
Normal 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");
|
||||
}
|
||||
}
|
||||
20
actions/WooCommerceCleanup.php
Normal file
20
actions/WooCommerceCleanup.php
Normal 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');
|
||||
}
|
||||
}
|
||||
15
actions/WooCommerceProductSummary.php
Normal file
15
actions/WooCommerceProductSummary.php
Normal 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');
|
||||
}
|
||||
}
|
||||
32
actions/WooCommerceProductTile.php
Normal file
32
actions/WooCommerceProductTile.php
Normal 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);
|
||||
}
|
||||
}
|
||||
26
actions/WooCommerceShopLayout.php
Normal file
26
actions/WooCommerceShopLayout.php
Normal 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');
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user