WMD Fixes

This commit is contained in:
Thomas Peterson 2024-09-10 12:58:00 +02:00
parent 6940033a77
commit 8d9e79c3bd
2 changed files with 32 additions and 19 deletions

View File

@ -6,7 +6,6 @@ use PSC\Library\Calc\Article;
class GetPrices extends Base
{
public function getPrices(Article $article): array
{
@ -26,7 +25,9 @@ class GetPrices extends Base
$response = $this->client->request(
'POST', $domain . 'orders:calculatePrices', [
'POST',
$domain . 'orders:calculatePrices',
[
'headers' =>
[...$this->buildHeaders(), ...$this->buildBearerTokenHeader()]
,
@ -35,7 +36,7 @@ class GetPrices extends Base
[
"product" => [
"attributes" => $attributes,
"quantity" => $article->getOptionById('auflage')->getValue(),
"quantity" => $article->getOptionById('auflage')->getRawValue(),
"productId" => $article->getOptionById('productId')->getValue(),
]
]

View File

@ -4,6 +4,7 @@ namespace Plugin\Custom\PSC\WMD_API\Controller;
use Doctrine\ODM\MongoDB\DocumentManager;
use Doctrine\ORM\EntityManagerInterface;
use PSC\Library\Calc\Option\Type\Select;
use Plugin\Custom\PSC\WMD_API\Model\Option;
use PSC\Library\Calc\Engine;
use PSC\Library\Calc\Option\Type\Base;
@ -11,14 +12,12 @@ use PSC\Shop\EntityBundle\Entity\Product;
use PSC\System\SettingsBundle\Service\Shop;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Component\HttpFoundation\JsonResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\Routing\Annotation\Route;
use Symfony\Component\Security\Core\Security;
class WMDController extends AbstractController
{
public function __construct()
{
}
@ -51,12 +50,26 @@ class WMDController extends AbstractController
$priceGross = 0;
$auflage = [
'defaultValue' => 1,
'defaultValue' => $engine->getArticle()->getOptionById('auflage')->getRawValue(),
'type' => 'input',
'label' => 'Auflage',
'id' => 'auflage'
];
if ($engine->getArticle()->getOptionById('auflage') instanceof Select) {
$auflage = [
'defaultValue' => $engine->getArticle()->getOptionById('auflage')->getRawValue(),
'type' => 'select',
'label' => 'Auflage',
'id' => 'auflage',
'values' => []
];
foreach ($engine->getArticle()->getOptionById('auflage')->getOptions() as $opt) {
$auflage['values'][] = ['id' => $opt->getId(), 'label' => $opt->getLabel()];
}
}
$versand = [
'defaultValue' => null,
'type' => 'select',
@ -126,4 +139,3 @@ class WMDController extends AbstractController
}