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

change shipping description

parent 06e38aa3
No related branches found
No related tags found
2 merge requests!201.0.41,!14Start webhook implementation
......@@ -1091,7 +1091,7 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
$signature = base64_encode($rawSignature);
// Set headers and post the data
$this->curl->addHeader('Content-Type', 'application/json');
$this->curl->addHeader('X-M-Webhook-Signature', $signature);
$this->curl->addHeader('x-m-webhook-signature', $signature);
$payloadJson = json_encode($payload);
$this->_logger->info('Webhooks payload: ' . $payloadJson);
......@@ -1108,20 +1108,13 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
$response = json_decode($responseBody, true);
if ($statusCode == 200 && isset($response['success']) && $response['success'] === true) {
$this->_logger->info('Webhook validation successful.');
// throw new LocalizedException(__('Rates received but id field is empty or invalid.'));
return true;
} else {
$this->_logger->error('Webhook validation failed: ' . ($response['message'] ?? 'Unknown error'));
// throw new LocalizedException(__('Rates received but id field is empty or invalid.'));
return false;
if ($statusCode != 200) {
throw new LocalizedException(__('Status code from BobGo: %1', $statusCode));
}
} catch (\Exception $e) {
$this->_logger->error('Webhook validation exception: ' . $e->getMessage());
// throw new LocalizedException(__('Rates received but id field is empty or invalid.'));
return false;
}
return true;
}
}
......@@ -26,5 +26,5 @@ class UData
*
* @var string
*/
public const WEBHOOK_URL = 'https://api.dev.bobgo.co.za/webhook/channel';
public const WEBHOOK_URL = 'https://api.dev.bobgo.co.za/webhook/channel/magento';
}
......@@ -73,10 +73,8 @@ class ConfigChangeObserver implements ObserverInterface
}
// Test for webhooks
if (is_array($changedPaths) && in_array('carriers/bobgo/enable_webhooks', $changedPaths)) {
$this->logger->info('Webhooks test start: ');
if ((is_array($changedPaths) && in_array('carriers/bobgo/enable_webhooks', $changedPaths)) || (is_array($changedPaths) && in_array('carriers/bobgo/webhook_key', $changedPaths))) {
$result = $this->bobGo->triggerWebhookTest();
$this->logger->info('Webhooks test end: ' . $result);
if ($this->bobGo->isWebhookEnabled()) {
if ($result) {
......
......@@ -25,26 +25,14 @@ class ModifyShippingDescription implements ObserverInterface
// Get the current shipping description
$shippingDescription = $order->getShippingDescription();
// Log the original shipping description
$this->logger->info('Original Shipping Description: ' . $shippingDescription);
// Get the shipping method used in the order (e.g., bobgo_10303_39_1)
$shippingMethod = $order->getShippingMethod();
// Get the method title from the shipping description (which might already include the title)
$methodTitle = $this->extractMethodTitle($shippingDescription);
// Log the method title for debugging
$this->logger->info('Extracted Method Title: ' . $methodTitle);
// Set the new dynamic shipping description based only on MethodTitle
$newDescription = $methodTitle;
// Update the shipping description in the order
$order->setShippingDescription($newDescription);
// Optionally log the new shipping description
$this->logger->info('Updated Shipping Description: ' . $newDescription);
}
/**
......
......@@ -66,7 +66,7 @@ abstract class OrderWebhookBase implements ObserverInterface
// Set headers and post the data
$this->curl->addHeader('Content-Type', 'application/json');
$this->curl->addHeader('X-M-Webhook-Signature', $signature);
$this->curl->addHeader('x-m-webhook-signature', $signature);
// Perform the API request
$payloadJson = json_encode($data);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment