WMD Fixes
This commit is contained in:
parent
6940033a77
commit
8d9e79c3bd
@ -6,7 +6,6 @@ use PSC\Library\Calc\Article;
|
||||
|
||||
class GetPrices extends Base
|
||||
{
|
||||
|
||||
public function getPrices(Article $article): array
|
||||
{
|
||||
|
||||
@ -14,19 +13,21 @@ class GetPrices extends Base
|
||||
|
||||
$attributes = [];
|
||||
foreach ($article->getOptions() as $option) {
|
||||
if($option->getId() != "productId" && $option->getId() != "auflage") {
|
||||
if ($option->getId() != "productId" && $option->getId() != "auflage") {
|
||||
$attributes[] = ['name' => $option->getId(), 'value' => $option->getValue()];
|
||||
}
|
||||
}
|
||||
|
||||
$domain = $this->liveUrl;
|
||||
if($this->test) {
|
||||
if ($this->test) {
|
||||
$domain = $this->stagingUrl;
|
||||
}
|
||||
|
||||
|
||||
$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(),
|
||||
]
|
||||
]
|
||||
|
||||
@ -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()
|
||||
{
|
||||
}
|
||||
@ -38,7 +37,7 @@ class WMDController extends AbstractController
|
||||
|
||||
$priceApi->setShop($shop->getMongoShopByUid($product->getShop()->getUID()));
|
||||
parse_str($request->get('config'), $reqConfig);
|
||||
if(isset($reqConfig['auflage'])) {
|
||||
if (isset($reqConfig['auflage'])) {
|
||||
$engine->setVariable('auflage', $reqConfig['auflage']);
|
||||
}
|
||||
$engine->calc();
|
||||
@ -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',
|
||||
@ -65,9 +78,9 @@ class WMDController extends AbstractController
|
||||
'id' => 'shipping'
|
||||
];
|
||||
|
||||
foreach($pricesArray as $priceObj) {
|
||||
foreach ($pricesArray as $priceObj) {
|
||||
$versand['values'][] = ['id' => $priceObj['deliveryOption'], 'label' => $priceObj['deliveryOption'], 'price' => $priceObj['price']['productPriceWithTax']['centAmount']];
|
||||
if(($price === 0 && !isset($reqConfig['shipping'])) ||
|
||||
if (($price === 0 && !isset($reqConfig['shipping'])) ||
|
||||
$price === 0 && isset($reqConfig['shipping']) && $reqConfig['shipping'] == $priceObj['deliveryOption']) {
|
||||
$price = $priceObj['price']['productPrice']['centAmount'];
|
||||
$priceVat = $priceObj['price']['productTax']['centAmount'];
|
||||
@ -76,15 +89,15 @@ class WMDController extends AbstractController
|
||||
|
||||
}
|
||||
|
||||
if(isset($reqConfig['shipping'])) {
|
||||
if (isset($reqConfig['shipping'])) {
|
||||
$versand['defaultValue'] = $reqConfig['shipping'];
|
||||
}
|
||||
|
||||
$config[] = $auflage;
|
||||
$config[] = $versand;
|
||||
|
||||
foreach($engine->getArticle()->getOptions() as $option) {
|
||||
if($option->getId() == "auflage") {
|
||||
foreach ($engine->getArticle()->getOptions() as $option) {
|
||||
if ($option->getId() == "auflage") {
|
||||
continue;
|
||||
}
|
||||
$config[] = [
|
||||
@ -108,7 +121,7 @@ class WMDController extends AbstractController
|
||||
#[Route('/storePrice', name: 'plugin_custom_psc_wmd_store_price')]
|
||||
public function storePrice(Request $request)
|
||||
{
|
||||
if(isset($_SESSION['Basket']['TempProduct'][$request->get('productId')])) {
|
||||
if (isset($_SESSION['Basket']['TempProduct'][$request->get('productId')])) {
|
||||
/**
|
||||
* @var \TP_Basket_Item $basketItem
|
||||
*/
|
||||
@ -126,4 +139,3 @@ class WMDController extends AbstractController
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user