Add dropdown filter. Add label rename variable products admin
This commit is contained in:
@@ -26,8 +26,8 @@ class PrijsPerPostcode
|
|||||||
public function init()
|
public function init()
|
||||||
{
|
{
|
||||||
$uri = $_SERVER["REQUEST_URI"];
|
$uri = $_SERVER["REQUEST_URI"];
|
||||||
add_filter("woocommerce_sale_flash", "__return_null");
|
|
||||||
init_postcode_handlers($uri);
|
init_postcode_handlers($uri);
|
||||||
|
add_filter("woocommerce_sale_flash", "__return_null");
|
||||||
|
|
||||||
//add_action("template_redirect", [$this, "redirect_if_missing_tag"]);
|
//add_action("template_redirect", [$this, "redirect_if_missing_tag"]);
|
||||||
add_action(
|
add_action(
|
||||||
@@ -57,6 +57,18 @@ class PrijsPerPostcode
|
|||||||
$this,
|
$this,
|
||||||
"controleer_postcode_op_woocommerce_paginas",
|
"controleer_postcode_op_woocommerce_paginas",
|
||||||
]);
|
]);
|
||||||
|
add_filter(
|
||||||
|
"woocommerce_variation_is_visible",
|
||||||
|
[$this, "filter_variation_by_local_price"],
|
||||||
|
10,
|
||||||
|
4,
|
||||||
|
);
|
||||||
|
add_filter(
|
||||||
|
"gettext",
|
||||||
|
[$this, "change_variation_regular_price_label"],
|
||||||
|
99,
|
||||||
|
3,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function add_local_price_field($loop, $variation_data, $variation)
|
public function add_local_price_field($loop, $variation_data, $variation)
|
||||||
@@ -155,6 +167,53 @@ class PrijsPerPostcode
|
|||||||
}
|
}
|
||||||
return $price_html;
|
return $price_html;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filter_variation_by_local_price(
|
||||||
|
$visible,
|
||||||
|
$variation_id,
|
||||||
|
$parent_id,
|
||||||
|
$variation,
|
||||||
|
) {
|
||||||
|
// Ensure $variation is a valid object
|
||||||
|
if (!$variation instanceof WC_Product_Variation) {
|
||||||
|
$variation = wc_get_product($variation_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!$variation) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$is_local = isset($_SESSION["postcode_is_local"])
|
||||||
|
? $_SESSION["postcode_is_local"]
|
||||||
|
: false;
|
||||||
|
$price = $is_local
|
||||||
|
? $variation->get_meta("_local_price", true)
|
||||||
|
: $variation->get_regular_price();
|
||||||
|
|
||||||
|
if (empty($price) || floatval($price) == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $visible;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function change_variation_regular_price_label(
|
||||||
|
$translated_text,
|
||||||
|
$text,
|
||||||
|
$domain,
|
||||||
|
) {
|
||||||
|
if (
|
||||||
|
"woocommerce" === $domain &&
|
||||||
|
is_admin() &&
|
||||||
|
isset($_REQUEST["action"]) &&
|
||||||
|
"woocommerce_load_variations" === $_REQUEST["action"]
|
||||||
|
) {
|
||||||
|
if ($translated_text === "Reguliere prijs (%s)") {
|
||||||
|
$translated_text = "Prijs overige regios (%s)";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $translated_text;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
new PrijsPerPostcode();
|
new PrijsPerPostcode();
|
||||||
|
|||||||
Reference in New Issue
Block a user