- Improved null safety by updating product ID retrieval logic in parsers and usage logs. - Enhanced primary wash item selection with stricter checks for valid product types. - Adjusted import date modifier in `importUsageLogs` for extended range (`-7 day`). - Streamlined product and user association in order creation with additional validations. - Removed redundant checks and refined permission handling in import tasks.
35 lines
1.2 KiB
PHP
35 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace helpers;
|
|
|
|
use Exception;
|
|
use objects\product_options_o;
|
|
use objects\products_o;
|
|
|
|
class xlvask_parser_undervognskylning extends xlvask_product_parser
|
|
{
|
|
use xlvask_product_parser_t;
|
|
|
|
public function __construct()
|
|
{
|
|
$this->setup('Undervognskylning'); // This is the name of Spot free product(s)
|
|
}
|
|
|
|
|
|
/**
|
|
* @inheritDoc
|
|
* @throws Exception
|
|
*/
|
|
protected function parse(xlvask_wash_item $wash_item, xlvask_usage_log $xlvask_usage_log): products_o
|
|
{
|
|
// This means that we need to check the vehicle type and return the appropriate product.
|
|
$primary_product_id = $xlvask_usage_log->getPrimaryItem()?->getProduct($xlvask_usage_log)?->id ?? null;
|
|
// Get the available addons for the primary product
|
|
$product_options = new product_options_o();
|
|
if (empty($primary_product_id) || $product_options->isOptionAllowedOnType(21, $primary_product_id)) {
|
|
return (new products_o())->select(21); // Undervognskylning product ID
|
|
}
|
|
// Throw an exception if the vehicle type is not supported
|
|
throw new Exception('Unsupported vehicle type for Undervognskylning');
|
|
}
|
|
} |