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

Get the service level code

parent d9bbff7b
No related branches found
No related tags found
1 merge request!6Rates at checkout
...@@ -827,41 +827,59 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car ...@@ -827,41 +827,59 @@ class BobGo extends AbstractCarrierOnline implements \Magento\Shipping\Model\Car
$result->append($error); $result->append($error);
} else { } else {
$this->_logger->info('Rates is not empty:'); $this->_logger->info('Rates are not empty.');
foreach ($rates['rates'] as $title) {
foreach ($rates['rates'] as $rate) {
$method = $this->_rateMethodFactory->create(); $method = $this->_rateMethodFactory->create();
if (isset($title)){
if (isset($rate)) {
// Set the carrier code
$method->setCarrier(self::CODE); $method->setCarrier(self::CODE);
// Log the original service code
$this->_logger->info('Original service code: ' . $rate['service_code']);
// Strip out the redundant 'bobgo_' prefix if present
$serviceCode = $rate['service_code'];
if (strpos($serviceCode, 'bobgo_') === 0) {
$serviceCode = substr($serviceCode, strlen('bobgo_'));
}
// Log the modified service code
$this->_logger->info('Modified service code: ' . $serviceCode);
// Set the method with the modified service code
$method->setMethod($serviceCode);
// Set additional info if required
if ($this->getConfigData('additional_info') == 1) { if ($this->getConfigData('additional_info') == 1) {
$min_delivery_date = $this->getWorkingDays(date('Y-m-d'), $title['min_delivery_date']); $min_delivery_date = $this->getWorkingDays(date('Y-m-d'), $rate['min_delivery_date']);
$max_delivery_date = $this->getWorkingDays(date('Y-m-d'), $title['max_delivery_date']); $max_delivery_date = $this->getWorkingDays(date('Y-m-d'), $rate['max_delivery_date']);
$this->deliveryDays($min_delivery_date, $max_delivery_date, $method); $this->deliveryDays($min_delivery_date, $max_delivery_date, $method);
} }
} // Set the method title, price, and cost
$method->setMethodTitle($rate['service_name']);
$price = $rate['total_price'];
$cost = $rate['total_price'];
$method->setMethod($title['service_code']); $method->setPrice($price);
$method->setMethodTitle($title['service_name']); $method->setCost($cost);
$price = $title['total_price'];
$cost = $title['total_price'];
// Log the values // Log the values
$this->_logger->info('Price: ' . $price); $this->_logger->info('Price: ' . $price);
$this->_logger->info('Cost: ' . $cost); $this->_logger->info('Cost: ' . $cost);
// Set the values
$method->setPrice($price);
$method->setCost($cost);
$result->append($method); $result->append($method);
} }
} }
} }
}
/** /**
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment