Feature/TWEB-143 woo order data to sf

This commit is contained in:
Tony Volpe
2024-10-16 23:56:36 +00:00
parent a6fc17dcaa
commit 31eacf670a
6 changed files with 758 additions and 248 deletions

View File

@@ -51,10 +51,6 @@ $AddOnsOnetime = array_filter(get_field("one_time_add_ons", "options"), function
return in_array($item["product_id"], $addOn["available_for_products"]);
});
// $normalizedonetime = strtolower(preg_replace('/\s+/', '', $_SESSION["one-time"]));
// $normalizedgetaddon = strtolower(preg_replace('/\s+/', '', $_GET["add-on"]));
if (isset($_GET["add-on"])) {
$addon = $_GET["add-on"];
if (stripos($addon, "Professional Install") !== false) {
@@ -62,44 +58,42 @@ if (isset($_GET["add-on"])) {
unset($_SESSION["one-time"]);
} else {
foreach ($AddOnsOnetime as $ao) {
if ($_GET["add-on"] == $ao["label"]) { // compare the $_GET param to available add ons
if ($_GET["add-on"] == $ao["label"]) {
$_SESSION["one-time"][$_GET["add-on"]] = $ao;
//$_SESSION["one-time"][$_GET["add-on"]] = "Professional Install";
break;
}
}
}
}
}
}
//var_dump($_SESSION["one-time"]);
// next, check the $_GET params to see if we need to toggle any add ons
if (isset($_GET["add-on"])) {
$add_on_modified = false;
if (isset($_SESSION["addOns"][$_GET["add-on"]])) {
unset($_SESSION["addOns"][$_GET["add-on"]]);
$add_on_modified = true;
} else {
foreach ($availableAddOns as $ao) {
if ($_GET["add-on"] == $ao["label"]) { // compare the $_GET param to available add ons
if ($_GET["add-on"] == $ao["label"]) {
$_SESSION["addOns"][$_GET["add-on"]] = $ao;
$add_on_modified = true;
break;
}
}
}
// back button toggles weird things when we are constantly juggling the
// $_SESSION based on $_GET, so let's redirect to a clean CART url
header("Location: ".wc_get_cart_url());
exit();
if ($add_on_modified) {
$redirect_url = remove_query_arg('add-on', wc_get_cart_url());
wp_redirect($redirect_url);
exit();
}
}
// next, check to see if we have any add ons currently enabled
foreach ($availableAddOns as $key => $addOn) {
$availableAddOns[$key]["in_cart"] = isset($_SESSION["addOns"][$addOn["label"]]);
}
//$AddOnsOnetime["in_cart"] = isset($_SESSION["one-time"]);
foreach ($AddOnsOnetime as $mykey => $oneTime) {
$AddOnsOnetime[$mykey]["in_cart"] = isset($_SESSION["one-time"]);
}
@@ -121,11 +115,8 @@ foreach ($availableAddOns as &$addOn) {
if ($addOn["label"] === "Key Lockbox") {
$addOn["price"] = "0.00";
}
}
}
}
$addOnOutput = site()->view("add_on_chooser", [
"add-ons" => $availableAddOns,
@@ -157,7 +148,4 @@ echo site()->view("cart", [
"couponSummary" => $couponSummary,
]);
// take it away from here!
get_footer();