Compare commits
2 Commits
reset-post
...
18bf4e3ada
| Author | SHA1 | Date | |
|---|---|---|---|
| 18bf4e3ada | |||
|
|
6fd3f4a13c |
@@ -26,8 +26,8 @@ class PrijsPerPostcode
|
||||
public function init()
|
||||
{
|
||||
$uri = $_SERVER["REQUEST_URI"];
|
||||
add_filter("woocommerce_sale_flash", "__return_null");
|
||||
init_postcode_handlers($uri);
|
||||
add_filter("woocommerce_sale_flash", "__return_null");
|
||||
|
||||
//add_action("template_redirect", [$this, "redirect_if_missing_tag"]);
|
||||
add_action(
|
||||
@@ -57,6 +57,18 @@ class PrijsPerPostcode
|
||||
$this,
|
||||
"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)
|
||||
@@ -155,6 +167,53 @@ class PrijsPerPostcode
|
||||
}
|
||||
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();
|
||||
|
||||
5
read.md
5
read.md
@@ -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.
|
||||
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user