Compare commits

..

2 Commits

Author SHA1 Message Date
18bf4e3ada Update read.md 2026-05-15 11:54:31 +02:00
Remo Zaros
6fd3f4a13c Add dropdown filter. Add label rename variable products admin 2026-05-14 15:04:55 +02:00
2 changed files with 65 additions and 1 deletions

View File

@@ -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();

View File

@@ -5,3 +5,8 @@ Deze plugin laat verschillende producten zien in Woocommerce naar aanleiding van
Een postcode in de 5000/5800 range laat producten zien met de tag "lokaal". Als een postcode buiten deze range ligt laat Woocommerce producten zien met de tag "algemeen". Een product moet de tag "lokaal" of "algemeen" hebben om in de winkel te verschijnen. Een postcode in de 5000/5800 range laat producten zien met de tag "lokaal". Als een postcode buiten deze range ligt laat Woocommerce producten zien met de tag "algemeen". Een product moet de tag "lokaal" of "algemeen" hebben om in de winkel te verschijnen.
Bij het opgeven van de postcode en huisnummer wordt de straatnaam en woonplaats opgezocht. Deze informatie wordt ingevuld tijdens het checkout process. Bij het opgeven van de postcode en huisnummer wordt de straatnaam en woonplaats opgezocht. Deze informatie wordt ingevuld tijdens het checkout process.
- [ ] code warning
- [ ] shop filter
- [ ] range postcodes
= [ ] pop up stylen