Skip to content
Snippets Groups Projects
Commit 524ce233 authored by Christel Loftus's avatar Christel Loftus
Browse files

Clean identifier url

parent a0918ae5
No related branches found
No related tags found
1 merge request!14Start webhook implementation
...@@ -110,6 +110,22 @@ class OrderCreateWebhook implements ObserverInterface ...@@ -110,6 +110,22 @@ class OrderCreateWebhook implements ObserverInterface
private function getStoreUrl(): string private function getStoreUrl(): string
{ {
return $this->storeManager->getStore()->getBaseUrl(); $url = $this->storeManager->getStore()->getBaseUrl();
// Remove protocol (http:// or https://)
$host = preg_replace('#^https?://#', '', $url);
// Ensure $host is a string before using it in explode
$host = $host ?? '';
// Remove everything after the host (e.g., paths, query strings)
$host = explode('/', $host)[0];
// If the host starts with 'www.', remove it
if (strpos($host, 'www.') === 0) {
$host = substr($host, 4);
}
return $host;
} }
} }
...@@ -109,6 +109,22 @@ class OrderUpdateWebhook implements ObserverInterface ...@@ -109,6 +109,22 @@ class OrderUpdateWebhook implements ObserverInterface
private function getStoreUrl(): string private function getStoreUrl(): string
{ {
return $this->storeManager->getStore()->getBaseUrl(); $url = $this->storeManager->getStore()->getBaseUrl();
// Remove protocol (http:// or https://)
$host = preg_replace('#^https?://#', '', $url);
// Ensure $host is a string before using it in explode
$host = $host ?? '';
// Remove everything after the host (e.g., paths, query strings)
$host = explode('/', $host)[0];
// If the host starts with 'www.', remove it
if (strpos($host, 'www.') === 0) {
$host = substr($host, 4);
}
return $host;
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment