WMD Fixes
This commit is contained in:
parent
6940033a77
commit
8d9e79c3bd
@ -6,7 +6,6 @@ use PSC\Library\Calc\Article;
|
|||||||
|
|
||||||
class GetPrices extends Base
|
class GetPrices extends Base
|
||||||
{
|
{
|
||||||
|
|
||||||
public function getPrices(Article $article): array
|
public function getPrices(Article $article): array
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -14,19 +13,21 @@ class GetPrices extends Base
|
|||||||
|
|
||||||
$attributes = [];
|
$attributes = [];
|
||||||
foreach ($article->getOptions() as $option) {
|
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()];
|
$attributes[] = ['name' => $option->getId(), 'value' => $option->getValue()];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$domain = $this->liveUrl;
|
$domain = $this->liveUrl;
|
||||||
if($this->test) {
|
if ($this->test) {
|
||||||
$domain = $this->stagingUrl;
|
$domain = $this->stagingUrl;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
$response = $this->client->request(
|
$response = $this->client->request(
|
||||||
'POST', $domain . 'orders:calculatePrices', [
|
'POST',
|
||||||
|
$domain . 'orders:calculatePrices',
|
||||||
|
[
|
||||||
'headers' =>
|
'headers' =>
|
||||||
[...$this->buildHeaders(), ...$this->buildBearerTokenHeader()]
|
[...$this->buildHeaders(), ...$this->buildBearerTokenHeader()]
|
||||||
,
|
,
|
||||||
@ -35,7 +36,7 @@ class GetPrices extends Base
|
|||||||
[
|
[
|
||||||
"product" => [
|
"product" => [
|
||||||
"attributes" => $attributes,
|
"attributes" => $attributes,
|
||||||
"quantity" => $article->getOptionById('auflage')->getValue(),
|
"quantity" => $article->getOptionById('auflage')->getRawValue(),
|
||||||
"productId" => $article->getOptionById('productId')->getValue(),
|
"productId" => $article->getOptionById('productId')->getValue(),
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
|||||||
@ -4,6 +4,7 @@ namespace Plugin\Custom\PSC\WMD_API\Controller;
|
|||||||
|
|
||||||
use Doctrine\ODM\MongoDB\DocumentManager;
|
use Doctrine\ODM\MongoDB\DocumentManager;
|
||||||
use Doctrine\ORM\EntityManagerInterface;
|
use Doctrine\ORM\EntityManagerInterface;
|
||||||
|
use PSC\Library\Calc\Option\Type\Select;
|
||||||
use Plugin\Custom\PSC\WMD_API\Model\Option;
|
use Plugin\Custom\PSC\WMD_API\Model\Option;
|
||||||
use PSC\Library\Calc\Engine;
|
use PSC\Library\Calc\Engine;
|
||||||
use PSC\Library\Calc\Option\Type\Base;
|
use PSC\Library\Calc\Option\Type\Base;
|
||||||
@ -11,14 +12,12 @@ use PSC\Shop\EntityBundle\Entity\Product;
|
|||||||
use PSC\System\SettingsBundle\Service\Shop;
|
use PSC\System\SettingsBundle\Service\Shop;
|
||||||
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
||||||
use Symfony\Component\HttpFoundation\JsonResponse;
|
use Symfony\Component\HttpFoundation\JsonResponse;
|
||||||
|
|
||||||
use Symfony\Component\HttpFoundation\Request;
|
use Symfony\Component\HttpFoundation\Request;
|
||||||
use Symfony\Component\Routing\Annotation\Route;
|
use Symfony\Component\Routing\Annotation\Route;
|
||||||
use Symfony\Component\Security\Core\Security;
|
use Symfony\Component\Security\Core\Security;
|
||||||
|
|
||||||
class WMDController extends AbstractController
|
class WMDController extends AbstractController
|
||||||
{
|
{
|
||||||
|
|
||||||
public function __construct()
|
public function __construct()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -29,7 +28,7 @@ class WMDController extends AbstractController
|
|||||||
|
|
||||||
$product = $entityManager->getRepository(Product::class)->findOneBy(['uuid' => $request->get('productId')]);
|
$product = $entityManager->getRepository(Product::class)->findOneBy(['uuid' => $request->get('productId')]);
|
||||||
/**
|
/**
|
||||||
* @var \PSC\Shop\EntityBundle\Document\Product $productDoc
|
* @var \PSC\Shop\EntityBundle\Document\Product $productDoc
|
||||||
*/
|
*/
|
||||||
$productDoc = $documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Product::class)->findOneBy(['uid' => $product->getUid()]);
|
$productDoc = $documentManager->getRepository(\PSC\Shop\EntityBundle\Document\Product::class)->findOneBy(['uid' => $product->getUid()]);
|
||||||
|
|
||||||
@ -38,7 +37,7 @@ class WMDController extends AbstractController
|
|||||||
|
|
||||||
$priceApi->setShop($shop->getMongoShopByUid($product->getShop()->getUID()));
|
$priceApi->setShop($shop->getMongoShopByUid($product->getShop()->getUID()));
|
||||||
parse_str($request->get('config'), $reqConfig);
|
parse_str($request->get('config'), $reqConfig);
|
||||||
if(isset($reqConfig['auflage'])) {
|
if (isset($reqConfig['auflage'])) {
|
||||||
$engine->setVariable('auflage', $reqConfig['auflage']);
|
$engine->setVariable('auflage', $reqConfig['auflage']);
|
||||||
}
|
}
|
||||||
$engine->calc();
|
$engine->calc();
|
||||||
@ -51,12 +50,26 @@ class WMDController extends AbstractController
|
|||||||
$priceGross = 0;
|
$priceGross = 0;
|
||||||
|
|
||||||
$auflage = [
|
$auflage = [
|
||||||
'defaultValue' => 1,
|
'defaultValue' => $engine->getArticle()->getOptionById('auflage')->getRawValue(),
|
||||||
'type' => 'input',
|
'type' => 'input',
|
||||||
'label' => 'Auflage',
|
'label' => 'Auflage',
|
||||||
'id' => '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 = [
|
$versand = [
|
||||||
'defaultValue' => null,
|
'defaultValue' => null,
|
||||||
'type' => 'select',
|
'type' => 'select',
|
||||||
@ -65,9 +78,9 @@ class WMDController extends AbstractController
|
|||||||
'id' => 'shipping'
|
'id' => 'shipping'
|
||||||
];
|
];
|
||||||
|
|
||||||
foreach($pricesArray as $priceObj) {
|
foreach ($pricesArray as $priceObj) {
|
||||||
$versand['values'][] = ['id' => $priceObj['deliveryOption'], 'label' => $priceObj['deliveryOption'], 'price' => $priceObj['price']['productPriceWithTax']['centAmount']];
|
$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 === 0 && isset($reqConfig['shipping']) && $reqConfig['shipping'] == $priceObj['deliveryOption']) {
|
||||||
$price = $priceObj['price']['productPrice']['centAmount'];
|
$price = $priceObj['price']['productPrice']['centAmount'];
|
||||||
$priceVat = $priceObj['price']['productTax']['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'];
|
$versand['defaultValue'] = $reqConfig['shipping'];
|
||||||
}
|
}
|
||||||
|
|
||||||
$config[] = $auflage;
|
$config[] = $auflage;
|
||||||
$config[] = $versand;
|
$config[] = $versand;
|
||||||
|
|
||||||
foreach($engine->getArticle()->getOptions() as $option) {
|
foreach ($engine->getArticle()->getOptions() as $option) {
|
||||||
if($option->getId() == "auflage") {
|
if ($option->getId() == "auflage") {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
$config[] = [
|
$config[] = [
|
||||||
@ -108,9 +121,9 @@ class WMDController extends AbstractController
|
|||||||
#[Route('/storePrice', name: 'plugin_custom_psc_wmd_store_price')]
|
#[Route('/storePrice', name: 'plugin_custom_psc_wmd_store_price')]
|
||||||
public function storePrice(Request $request)
|
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
|
* @var \TP_Basket_Item $basketItem
|
||||||
*/
|
*/
|
||||||
$basketItem = $_SESSION['Basket']['TempProduct'][$request->get('productId')];
|
$basketItem = $_SESSION['Basket']['TempProduct'][$request->get('productId')];
|
||||||
$basketItem->setNetto($request->get('netto'));
|
$basketItem->setNetto($request->get('netto'));
|
||||||
@ -126,4 +139,3 @@ class WMDController extends AbstractController
|
|||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user